diff --git a/.mtn-ignore b/.mtn-ignore index 5b67e3e5..a0741418 100644 --- a/.mtn-ignore +++ b/.mtn-ignore @@ -1,2 +1,5 @@ env pots +\.pyc$ +\.pyo$ +~$ diff --git a/compile-messages.sh b/compile-messages.sh index bc2e8b7b..8dddd6e3 100755 --- a/compile-messages.sh +++ b/compile-messages.sh @@ -1,11 +1,13 @@ #!/bin/sh . ./etc/translation.vars +export TZ=UTC + if [ $# -ge 1 ] then - TZ=UTC env/bin/pybabel compile -D $1 -d $TRANSDIR + $PYBABEL compile -D $1 -d $TRANSDIR else for domain in $(ls $BABELCFG); do - TZ=UTC env/bin/pybabel compile -D $domain -d $TRANSDIR + $PYBABEL compile -D $domain -d $TRANSDIR done fi diff --git a/etc/reqs.txt b/etc/reqs.txt index df74394b..baa1939c 100644 --- a/etc/reqs.txt +++ b/etc/reqs.txt @@ -1,3 +1,4 @@ +pytz>=2012 Flask==0.9 Flask-Babel==0.8 Flask-Cache==0.10.1 diff --git a/etc/translation.vars b/etc/translation.vars index b892c1db..cc7998cc 100644 --- a/etc/translation.vars +++ b/etc/translation.vars @@ -4,3 +4,12 @@ BABELCFG=etc/babel.cfg POTDIR=pots PROJDIR=i2p2www TRANSDIR=$PROJDIR/translations + +if [ -x env/bin/pybabel ]; then + PYBABEL=env/bin/pybabel +elif [ $(which pybabel) ]; then + PYBABEL=$(which pybabel) +else + echo "ERROR: pybabel was not found. Please run setup_venv.sh" >&2 + exit 1 +fi diff --git a/extract-messages.sh b/extract-messages.sh index 71715320..bdb277be 100755 --- a/extract-messages.sh +++ b/extract-messages.sh @@ -1,13 +1,19 @@ #!/bin/sh . ./etc/translation.vars +export TZ=UTC + if [ ! -e $POTDIR ]; then mkdir $POTDIR fi +# By setting the PYTHONPATH here we can help pybabel find 'our' highlighting +# extension and we can use any pybabel +export PYTHONPATH=i2p2www:$PYTHONPATH + if [ $# -ge 1 ] then - TZ=UTC ./pybabel extract --msgid-bugs-address="http://trac.i2p2.de" \ + $PYBABEL extract --msgid-bugs-address="http://trac.i2p2.de" \ --project=$PROJECT \ --version=$VERSION \ -F $BABELCFG/$1 \ @@ -17,7 +23,7 @@ else if [ -e $POTDIR/$domain.pot ]; then mv $POTDIR/$domain.pot $POTDIR/$domain.pot.old fi - TZ=UTC ./pybabel extract --msgid-bugs-address="http://trac.i2p2.de" \ + $PYBABEL extract --msgid-bugs-address="http://trac.i2p2.de" \ --project=$PROJECT \ --version=$VERSION \ -F $BABELCFG/$domain \ diff --git a/i2p2www/__init__.py b/i2p2www/__init__.py index 1eb2a93e..939d9c24 100644 --- a/i2p2www/__init__.py +++ b/i2p2www/__init__.py @@ -1,6 +1,12 @@ from flask import Flask, request, g, redirect, url_for, abort, render_template, send_from_directory, safe_join -from flaskext.babel import Babel -from flask.ext.cache import Cache +try: + from flaskext.babel import Babel +except ImportError: + from flask_babel import Babel +try: + from flask.ext.cache import Cache +except ImportError: + from flask_cache import Cache from docutils.core import publish_parts import os.path import os diff --git a/i2p2www/translations/es/LC_MESSAGES/about.po b/i2p2www/translations/es/LC_MESSAGES/about.po index d7776095..f01c3b8f 100644 --- a/i2p2www/translations/es/LC_MESSAGES/about.po +++ b/i2p2www/translations/es/LC_MESSAGES/about.po @@ -1210,8 +1210,7 @@ msgid "" "German translation" msgstr "" "zzz entrevistado por gulli.com\n" -"Marzo de 2009\n" -"Traducción al alemán" +"href=\"%(german)s\">traducción en alemán" #: i2p2www/pages/site/about/media.html:202 #, python-format diff --git a/i2p2www/translations/es/LC_MESSAGES/docs.po b/i2p2www/translations/es/LC_MESSAGES/docs.po index 499a246c..04d89101 100644 --- a/i2p2www/translations/es/LC_MESSAGES/docs.po +++ b/i2p2www/translations/es/LC_MESSAGES/docs.po @@ -12854,7 +12854,7 @@ msgid "" "It is hosted on %(pybit)s " msgstr "" "PyBit es un cliente Bittorrent escrito en python. Se aloja en http://%(pebcache)s/ " #: i2p2www/pages/site/docs/how/tech-intro.html:1015 diff --git a/i2p2www/translations/es/LC_MESSAGES/priority.po b/i2p2www/translations/es/LC_MESSAGES/priority.po index d7e25e7f..2b2dea28 100644 --- a/i2p2www/translations/es/LC_MESSAGES/priority.po +++ b/i2p2www/translations/es/LC_MESSAGES/priority.po @@ -2316,7 +2316,7 @@ msgstr "" "Si considera todas las eepsites que se han creado, si, la mayoría no " "funcionan. La gente y las eepsites van y vienen. Una buena forma de " "comenzar con I2P es mirar la lista de eepsites que funcionan actualmente." -" %(perv)s informa qué " +" %(eepstatus)s informa qué " "páginas están activas." #: i2p2www/pages/site/faq.html:385 diff --git a/i2p2www/translations/fr/LC_MESSAGES/priority.po b/i2p2www/translations/fr/LC_MESSAGES/priority.po index 668e5736..5addcf70 100644 --- a/i2p2www/translations/fr/LC_MESSAGES/priority.po +++ b/i2p2www/translations/fr/LC_MESSAGES/priority.po @@ -2313,7 +2313,7 @@ msgstr "" "Les gens et les eepsites vont et viennent.\n" "Une bonne façon de se lancer dans I2P est de vérifier une liste de " "eepsites qui sont actuellement en place.\n" -"%(perv)s trace les eepsites " +"%(eepstatus)s trace les eepsites " "actifs." #: i2p2www/pages/site/faq.html:385 diff --git a/init-new-po.sh b/init-new-po.sh index 5a021c41..e8395ac2 100755 --- a/init-new-po.sh +++ b/init-new-po.sh @@ -1,10 +1,12 @@ #!/bin/sh . ./etc/translation.vars +export TZ=UTC + if [ $# -ge 1 ] then for domain in $(ls $BABELCFG); do - TZ=UTC env/bin/pybabel init -D $domain -i $POTDIR/$domain.pot -d $TRANSDIR -l $1 + $PYBABEL init -D $domain -i $POTDIR/$domain.pot -d $TRANSDIR -l $1 done else echo "Usage: ./init-new-po.sh lang" diff --git a/pybabel b/pybabel deleted file mode 100755 index 0c119a66..00000000 --- a/pybabel +++ /dev/null @@ -1,10 +0,0 @@ -#!env/bin/python -# EASY-INSTALL-ENTRY-SCRIPT: 'Babel==0.9.6','console_scripts','pybabel' -__requires__ = 'Babel==0.9.6' -import sys -from pkg_resources import load_entry_point - -if __name__ == '__main__': - sys.exit( - load_entry_point('Babel==0.9.6', 'console_scripts', 'pybabel')() - ) diff --git a/setup_venv.sh b/setup_venv.sh index e9ed695b..9b3b3a40 100755 --- a/setup_venv.sh +++ b/setup_venv.sh @@ -4,6 +4,7 @@ set -e if [ ! $venv ]; then echo "ERROR: virtualenv not found!" >&2 + exit 1 else if [ ! -d $venv_dir ] ; then $venv --distribute $venv_dir @@ -12,5 +13,5 @@ else . $venv_dir/bin/activate pip install -r etc/reqs.txt # Apply multi-domain patch to Flask-Babel - patch -p0 &1 | tee $TMP -cat $TMP | grep "^mtn: adding 'i2p2www/translations/\|^mtn: dropping 'i2p2www/translations/\|^mtn: updating 'i2p2www/translations/" >/dev/null -if [ $? -eq 0 ]; then +if grep "^mtn: \(add\|dropp\|updat\)ing 'i2p2www/translations/" "$TMP" >/dev/null; then echo "Translations updated, compiling messages" ./compile-messages-i2hq.sh fi -cat $TMP | grep "^mtn: updating 'i2p2www/.*\.py\|^mtn: updating 'i2p2www/.*/.*\.py" >/dev/null -if [ $? -eq 0 ]; then +if grep "^mtn: updating 'i2p2www/.*\.py\|^mtn: updating 'i2p2www/.*/.*\.py" >/dev/null; then echo "Python files changed, restarting server" touch /tmp/2fcd2f17-c293-4f77-b4c9-9b266ba70daa fi - -rm $TMP diff --git a/site-updater.sh b/site-updater.sh index d5366eaf..9fa5f7ea 100755 --- a/site-updater.sh +++ b/site-updater.sh @@ -1,18 +1,15 @@ #!/bin/sh -TMP=tmp +TMP=$(mktemp XXXXXXXXXX) +trap 'rm -f $TMP;exit' 0 1 2 15 mtn update 2>&1 | tee $TMP -cat $TMP | grep "^mtn: adding 'i2p2www/translations/\|^mtn: dropping 'i2p2www/translations/\|^mtn: updating 'i2p2www/translations/" >/dev/null -if [ $? -eq 0 ]; then +if grep "^mtn: \(add\|dropp\|updat\)ing 'i2p2www/translations/" "$TMP" >/dev/null ; then echo "Translations updated, compiling messages" ./compile-messages.sh fi -cat $TMP | grep "^mtn: updating 'i2p2www/.*\.py\|^mtn: updating 'i2p2www/.*/.*\.py" >/dev/null -if [ $? -eq 0 ]; then +if grep "^mtn: updating 'i2p2www/.*\.py\|^mtn: updating 'i2p2www/.*/.*\.py" "$TMP" >/dev/null ; then echo "Python files changed, restarting server" touch /tmp/2fcd2f17-c293-4f77-b4c9-9b266ba70daa fi - -rm $TMP diff --git a/update-existing-po.sh b/update-existing-po.sh index d423360d..4ddedef2 100755 --- a/update-existing-po.sh +++ b/update-existing-po.sh @@ -1,11 +1,12 @@ #!/bin/sh . ./etc/translation.vars +export TZ=UTC if [ $# -ge 1 ] then - TZ=UTC env/bin/pybabel update -D $1 -i $POTDIR/$1.pot -d $TRANSDIR + $PYBABEL update -D $1 -i $POTDIR/$1.pot -d $TRANSDIR else for domain in $(ls $BABELCFG); do - TZ=UTC env/bin/pybabel update -D $domain -i $POTDIR/$domain.pot -d $TRANSDIR + $PYBABEL update -D $domain -i $POTDIR/$domain.pot -d $TRANSDIR done fi