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).
This commit is contained in:
str4d
2013-07-13 11:01:05 +00:00
parent 177aecb55c
commit f9c88aa795
15 changed files with 51 additions and 21 deletions

View File

@ -1,2 +1,2 @@
env
.*\.pot
pots

2
babel.cfg/about Normal file
View File

@ -0,0 +1,2 @@
[jinja2: **/pages/site/about/**.html]
extensions=jinja2.ext.autoescape,jinja2.ext.with_,i2p2www.extensions.HighlightExtension

2
babel.cfg/blog Normal file
View File

@ -0,0 +1,2 @@
[jinja2: **/blog/**.rst]
extensions=jinja2.ext.autoescape,jinja2.ext.with_

2
babel.cfg/comparison Normal file
View File

@ -0,0 +1,2 @@
[jinja2: **/pages/site/comparison/**.html]
extensions=jinja2.ext.autoescape,jinja2.ext.with_,i2p2www.extensions.HighlightExtension

2
babel.cfg/docs Normal file
View File

@ -0,0 +1,2 @@
[jinja2: **/pages/site/docs/**.html]
extensions=jinja2.ext.autoescape,jinja2.ext.with_,i2p2www.extensions.HighlightExtension

2
babel.cfg/get-involved Normal file
View File

@ -0,0 +1,2 @@
[jinja2: **/pages/site/get-involved/**.html]
extensions=jinja2.ext.autoescape,jinja2.ext.with_,i2p2www.extensions.HighlightExtension

2
babel.cfg/misc Normal file
View File

@ -0,0 +1,2 @@
[jinja2: **/pages/site/misc/**.html]
extensions=jinja2.ext.autoescape,jinja2.ext.with_,i2p2www.extensions.HighlightExtension

12
babel.cfg/priority Normal file
View File

@ -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

2
babel.cfg/research Normal file
View File

@ -0,0 +1,2 @@
[jinja2: **/pages/site/research/**.html]
extensions=jinja2.ext.autoescape,jinja2.ext.with_,i2p2www.extensions.HighlightExtension

View File

@ -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_

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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