From f9c88aa795acf717f45a2eabc947d038675d9d63 Mon Sep 17 00:00:00 2001 From: str4d Date: Sat, 13 Jul 2013 11:01:05 +0000 Subject: [PATCH] Split translation strings between multiple domains This breaks translation processing; multi-domain support needs to be added to Flask-Babel. The changes made here put the "important" strings that are used most often into the priority domain, and split the content from different sub-urls into separate domains. Multi-domain support will be implemented such that translations for a specific request are pulled both from the domain which corresponds to the request url and the priority domain. This does mean that there may be duplication of translation strings between domains, but that is unavoidable (and the translators prefer working with smaller resource files). --- .mtn-ignore | 2 +- babel.cfg/about | 2 ++ babel.cfg/blog | 2 ++ babel.cfg/comparison | 2 ++ babel.cfg/docs | 2 ++ babel.cfg/get-involved | 2 ++ babel.cfg/misc | 2 ++ babel.cfg/priority | 12 ++++++++++++ babel.cfg/research | 2 ++ babel/babel.cfg | 7 ------- compile-messages.sh | 6 ++++-- extract-messages.sh | 14 ++++++++++---- init-new-po.sh | 6 ++++-- babel/translation.vars => translation.vars | 5 ++--- update-existing-po.sh | 6 ++++-- 15 files changed, 51 insertions(+), 21 deletions(-) create mode 100644 babel.cfg/about create mode 100644 babel.cfg/blog create mode 100644 babel.cfg/comparison create mode 100644 babel.cfg/docs create mode 100644 babel.cfg/get-involved create mode 100644 babel.cfg/misc create mode 100644 babel.cfg/priority create mode 100644 babel.cfg/research delete mode 100644 babel/babel.cfg rename babel/translation.vars => translation.vars (54%) diff --git a/.mtn-ignore b/.mtn-ignore index 189231b0..5b67e3e5 100644 --- a/.mtn-ignore +++ b/.mtn-ignore @@ -1,2 +1,2 @@ env -.*\.pot +pots diff --git a/babel.cfg/about b/babel.cfg/about new file mode 100644 index 00000000..a8cc71cc --- /dev/null +++ b/babel.cfg/about @@ -0,0 +1,2 @@ +[jinja2: **/pages/site/about/**.html] +extensions=jinja2.ext.autoescape,jinja2.ext.with_,i2p2www.extensions.HighlightExtension diff --git a/babel.cfg/blog b/babel.cfg/blog new file mode 100644 index 00000000..58f52396 --- /dev/null +++ b/babel.cfg/blog @@ -0,0 +1,2 @@ +[jinja2: **/blog/**.rst] +extensions=jinja2.ext.autoescape,jinja2.ext.with_ diff --git a/babel.cfg/comparison b/babel.cfg/comparison new file mode 100644 index 00000000..e113121d --- /dev/null +++ b/babel.cfg/comparison @@ -0,0 +1,2 @@ +[jinja2: **/pages/site/comparison/**.html] +extensions=jinja2.ext.autoescape,jinja2.ext.with_,i2p2www.extensions.HighlightExtension diff --git a/babel.cfg/docs b/babel.cfg/docs new file mode 100644 index 00000000..e37d7502 --- /dev/null +++ b/babel.cfg/docs @@ -0,0 +1,2 @@ +[jinja2: **/pages/site/docs/**.html] +extensions=jinja2.ext.autoescape,jinja2.ext.with_,i2p2www.extensions.HighlightExtension diff --git a/babel.cfg/get-involved b/babel.cfg/get-involved new file mode 100644 index 00000000..2b9e70eb --- /dev/null +++ b/babel.cfg/get-involved @@ -0,0 +1,2 @@ +[jinja2: **/pages/site/get-involved/**.html] +extensions=jinja2.ext.autoescape,jinja2.ext.with_,i2p2www.extensions.HighlightExtension diff --git a/babel.cfg/misc b/babel.cfg/misc new file mode 100644 index 00000000..ce64514f --- /dev/null +++ b/babel.cfg/misc @@ -0,0 +1,2 @@ +[jinja2: **/pages/site/misc/**.html] +extensions=jinja2.ext.autoescape,jinja2.ext.with_,i2p2www.extensions.HighlightExtension diff --git a/babel.cfg/priority b/babel.cfg/priority new file mode 100644 index 00000000..01a8fed1 --- /dev/null +++ b/babel.cfg/priority @@ -0,0 +1,12 @@ +[jinja2: **/pages/blog/**.html] +extensions=jinja2.ext.autoescape,jinja2.ext.with_,i2p2www.extensions.HighlightExtension +[jinja2: **/pages/download/**.html] +extensions=jinja2.ext.autoescape,jinja2.ext.with_,i2p2www.extensions.HighlightExtension +[jinja2: **/pages/global/**.html] +extensions=jinja2.ext.autoescape,jinja2.ext.with_,i2p2www.extensions.HighlightExtension +[jinja2: **/pages/global/macros] +extensions=jinja2.ext.autoescape,jinja2.ext.with_ +[jinja2: **/pages/meetings/**.html] +extensions=jinja2.ext.autoescape,jinja2.ext.with_,i2p2www.extensions.HighlightExtension +[jinja2: **/pages/site/*.html] +extensions=jinja2.ext.autoescape,jinja2.ext.with_,i2p2www.extensions.HighlightExtension diff --git a/babel.cfg/research b/babel.cfg/research new file mode 100644 index 00000000..59607bd9 --- /dev/null +++ b/babel.cfg/research @@ -0,0 +1,2 @@ +[jinja2: **/pages/site/research/**.html] +extensions=jinja2.ext.autoescape,jinja2.ext.with_,i2p2www.extensions.HighlightExtension diff --git a/babel/babel.cfg b/babel/babel.cfg deleted file mode 100644 index f25e938a..00000000 --- a/babel/babel.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[python: **.py] -[jinja2: **/pages/**.html] -extensions=jinja2.ext.autoescape,jinja2.ext.with_,i2p2www.extensions.HighlightExtension -[jinja2: **/pages/global/macros] -extensions=jinja2.ext.autoescape,jinja2.ext.with_ -[jinja2: **/blog/**.rst] -extensions=jinja2.ext.autoescape,jinja2.ext.with_ diff --git a/compile-messages.sh b/compile-messages.sh index e646bbe0..42bf6326 100755 --- a/compile-messages.sh +++ b/compile-messages.sh @@ -1,4 +1,6 @@ #!/bin/sh -. ./babel/translation.vars +. ./translation.vars -TZ=UTC env/bin/pybabel compile -d $TRANSDIR +for domain in $(ls $BABELCFG); do + TZ=UTC env/bin/pybabel compile -D $domain -d $TRANSDIR +done diff --git a/extract-messages.sh b/extract-messages.sh index 6711f927..62e3dc81 100755 --- a/extract-messages.sh +++ b/extract-messages.sh @@ -1,8 +1,14 @@ #!/bin/sh -. ./babel/translation.vars +. ./translation.vars -TZ=UTC ./pybabel extract --msgid-bugs-address="http://trac.i2p2.de" \ +if [ ! -e $POTDIR ]; then + mkdir $POTDIR +fi + +for domain in $(ls $BABELCFG); do + TZ=UTC ./pybabel extract --msgid-bugs-address="http://trac.i2p2.de" \ --project=$PROJECT \ --version=$VERSION \ - -F $BABELCFG \ - -o $POTFILE $PROJDIR + -F $BABELCFG/$domain \ + -o $POTDIR/$domain.pot $PROJDIR +done diff --git a/init-new-po.sh b/init-new-po.sh index 0d758241..71a50008 100755 --- a/init-new-po.sh +++ b/init-new-po.sh @@ -1,9 +1,11 @@ #!/bin/sh -. ./babel/translation.vars +. ./translation.vars if [ $# -ge 1 ] then - TZ=UTC env/bin/pybabel init -i $POTFILE -d $TRANSDIR -l $1 + for domain in $(ls $BABELCFG); do + TZ=UTC env/bin/pybabel init -D $domain -i $POTDIR/$domain.pot -d $TRANSDIR -l $1 + done else echo "Usage: ./init-new-po.sh lang" fi diff --git a/babel/translation.vars b/translation.vars similarity index 54% rename from babel/translation.vars rename to translation.vars index da87837c..46ccc9ea 100644 --- a/babel/translation.vars +++ b/translation.vars @@ -1,7 +1,6 @@ PROJECT=I2P VERSION=website -CONFDIR=babel +BABELCFG=babel.cfg +POTDIR=pots PROJDIR=i2p2www -BABELCFG=$CONFDIR/babel.cfg -POTFILE=messages.pot TRANSDIR=$PROJDIR/translations diff --git a/update-existing-po.sh b/update-existing-po.sh index c87790e2..fc43574a 100755 --- a/update-existing-po.sh +++ b/update-existing-po.sh @@ -1,4 +1,6 @@ #!/bin/sh -. ./babel/translation.vars +. ./translation.vars -TZ=UTC env/bin/pybabel update -i $POTFILE -d $TRANSDIR +for domain in $(ls $BABELCFG); do + TZ=UTC env/bin/pybabel update -D $domain -i $POTDIR/$domain.pot -d $TRANSDIR +done