From 7e086fd2e77b0a1bda9bd2d4374cf5f35ffd76b6 Mon Sep 17 00:00:00 2001 From: kytv Date: Sat, 31 Aug 2013 23:30:36 +0000 Subject: [PATCH 1/8] workaround flask bug by explicitly installing pytz before flask --- etc/reqs.txt | 1 + 1 file changed, 1 insertion(+) 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 From ba651ceafb26f6dafc7c5136e3aaf791436f50de Mon Sep 17 00:00:00 2001 From: kytv Date: Sat, 31 Aug 2013 23:52:07 +0000 Subject: [PATCH 2/8] site-updater updates - no unneccesary uses of cat - create tempfile with mktemp and cleanup with a trap - simplify regex --- site-updater-i2hq.sh | 11 ++++------- site-updater.sh | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/site-updater-i2hq.sh b/site-updater-i2hq.sh index b12c2d23..28b3452d 100755 --- a/site-updater-i2hq.sh +++ b/site-updater-i2hq.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-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 From 5c7672eb1c4b5ca80fea0de40cf29c5ce4216a39 Mon Sep 17 00:00:00 2001 From: kytv Date: Sat, 31 Aug 2013 23:58:20 +0000 Subject: [PATCH 3/8] prefer the venv pybabel but allow the system one to be used (if found) --- compile-messages.sh | 6 ++++-- etc/translation.vars | 9 +++++++++ extract-messages.sh | 10 ++++++++-- init-new-po.sh | 4 +++- update-existing-po.sh | 5 +++-- 5 files changed, 27 insertions(+), 7 deletions(-) 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/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 fb7250d9..d8b7de1e 100755 --- a/extract-messages.sh +++ b/extract-messages.sh @@ -1,20 +1,26 @@ #!/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 \ -o $POTDIR/$1.pot $PROJDIR else for domain in $(ls $BABELCFG); do - 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/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/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 From fb54baaf77572c8fd6af8aff37b1cc3506147352 Mon Sep 17 00:00:00 2001 From: kytv Date: Sat, 31 Aug 2013 23:59:03 +0000 Subject: [PATCH 4/8] allow system flask-cache/babel to be used --- i2p2www/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 From 8059c7fdcf3397dad51466031cd95bacd4488b20 Mon Sep 17 00:00:00 2001 From: kytv Date: Sun, 1 Sep 2013 00:00:01 +0000 Subject: [PATCH 5/8] add temp- and byte-compiled files to the ignore list --- .mtn-ignore | 3 +++ 1 file changed, 3 insertions(+) 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$ +~$ From ef592ad9957579f24e5b66d5489b90ffe6f8b2b2 Mon Sep 17 00:00:00 2001 From: kytv Date: Sun, 1 Sep 2013 00:05:24 +0000 Subject: [PATCH 6/8] only allow "forward" patches & exit 1 if virtualenv isn't found --- setup_venv.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 Date: Sun, 1 Sep 2013 22:24:44 +0000 Subject: [PATCH 7/8] droping unnecessary (and outdated) pybabel extract-messages.sh was 'fixed' in ff0e551bd7eaa9cb26d14a6606d66eb4ae9de7e0 --- pybabel | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100755 pybabel 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')() - ) From d7d3f5fc4f27a868a018bdc05e02e85cb5a44375 Mon Sep 17 00:00:00 2001 From: kytv Date: Mon, 2 Sep 2013 01:50:12 +0000 Subject: [PATCH 8/8] fix errors in po files --- i2p2www/translations/es/LC_MESSAGES/about.po | 3 +-- i2p2www/translations/es/LC_MESSAGES/docs.po | 2 +- i2p2www/translations/es/LC_MESSAGES/priority.po | 2 +- i2p2www/translations/fr/LC_MESSAGES/priority.po | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/i2p2www/translations/es/LC_MESSAGES/about.po b/i2p2www/translations/es/LC_MESSAGES/about.po index 5f70cc9f..a15b48e4 100644 --- a/i2p2www/translations/es/LC_MESSAGES/about.po +++ b/i2p2www/translations/es/LC_MESSAGES/about.po @@ -1202,8 +1202,7 @@ msgid "" "German translation" msgstr "" "zzz entrevistado por gulli.com⏎ Marzo 2009⏎ traducción en alemán traducción en ruso" +"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 8648297d..0ce6d92e 100644 --- a/i2p2www/translations/es/LC_MESSAGES/docs.po +++ b/i2p2www/translations/es/LC_MESSAGES/docs.po @@ -11404,7 +11404,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 43f3353d..32ddc9ce 100644 --- a/i2p2www/translations/es/LC_MESSAGES/priority.po +++ b/i2p2www/translations/es/LC_MESSAGES/priority.po @@ -2282,7 +2282,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