Skip to content

Commit f00c596

Browse files
committed
Add babel translation scripts
1 parent 3c5513a commit f00c596

7 files changed

+52
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ public
33
*.pyc
44
pelican.pid
55
srv.pid
6+
themes/i18n/translations/*/LC_MESSAGES/*.mo
67

78
# This is a generic Python gitignore
89
# https://github.com/github/gitignore/blob/2eba0d635f6f5f1b22a4ad99dcc9da0c11da2208/Python.gitignore

i18n-add-language.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
export TZ=UTC
4+
5+
pybabel init -i themes/i18n/messages.pot -d themes/i18n/translations -l $1

i18n-compile-po.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
export TZ=UTC
4+
5+
pybabel compile -d themes/i18n/translations

i18n-extract-messages.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
export TZ=UTC
4+
5+
if [ -e themes/i18n/messages.pot ]; then
6+
mv themes/i18n/messages.pot themes/i18n/messages.pot.old
7+
fi
8+
9+
pybabel extract --msgid-bugs-address="https://github.com/Tox/tox.chat/issues" \
10+
--copyright-holder="Project Tox Website Contributors" \
11+
--project="Tox Website" \
12+
--version="(https://tox.chat)" \
13+
--sort-by-file \
14+
-F themes/i18n/babel.cfg \
15+
-o themes/i18n/messages.pot \
16+
.
17+
18+
if [ -e themes/i18n/messages.pot.old ]; then
19+
if diff -u <(sed '/POT-Creation-Date/d' themes/i18n/messages.pot) <(sed '/POT-Creation-Date/d' themes/i18n/messages.pot.old); then
20+
echo "No translation strings changed, keeping the old POT"
21+
mv themes/i18n/messages.pot.old themes/i18n/messages.pot
22+
else
23+
echo "Translation strings changed, using the new POT"
24+
rm themes/i18n/messages.pot.old
25+
fi
26+
fi
27+

i18n-update-po.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
export TZ=UTC
4+
5+
pybabel update -i themes/i18n/messages.pot -d themes/i18n/translations
6+
7+
for file in themes/i18n/translations/*/LC_MESSAGES/*.po; do
8+
sed -i '/^#~/,+2d' $file
9+
done
10+

pelicanconf.py

+1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ def copy_list(l):
211211
# https://github.com/getpelican/pelican-plugins/tree/master/i18n_subsites
212212
# http://jinja.pocoo.org/docs/2.10/templates/#i18n
213213
# http://mozweb.readthedocs.io/en/latest/reference/l10n.html
214+
I18N_GETTEXT_LOCALEDIR = 'themes/i18n/translations'
214215
I18N_UNTRANSLATED_ARTICLES = 'keep'
215216
I18N_UNTRANSLATED_PAGES = 'keep'
216217
I18N_SUBSITES = {

themes/i18n/babel.cfg

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[jinja2: themes/global/templates/**.html]
2+
[jinja2: themes/website/templates/**.html]
3+
[jinja2: themes/blog/templates/**.html]

0 commit comments

Comments
 (0)