diff --git a/python/web/README.md b/python/web/README.md index 55f1404e..69a4df71 100644 --- a/python/web/README.md +++ b/python/web/README.md @@ -73,12 +73,14 @@ When adding a localization for a new language, initialize the directory structur $ pybabel init -i messages.pot -d src/translations -l xx ``` -### Update an existing loclization +### Update an existing localization + +Tip: Use the script **translation_update.sh** in this dir to automatically extract strings, update existing localizations, and print translation statistics. After strings have been added or changed in the code, update the existing localizations. ``` -pybabel update -i messages.pot -d src/translations +$ pybabel update -i messages.pot -d src/translations ``` Then edit the updated messages.po file for your language. Make sure to update fuzzy strings and translate new ones. diff --git a/python/web/translation_update.sh b/python/web/translation_update.sh new file mode 100755 index 00000000..fa448862 --- /dev/null +++ b/python/web/translation_update.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -e + +cd "$(dirname "$0")" +# Check for the existence of a python venv in the current dir +if ! test -e venv; then + echo "No python venv detected. Please run start.sh first." + exit 1 +fi + +source venv/bin/activate + +pybabel extract -F babel.cfg -o messages.pot . +pybabel update -i messages.pot -d src/translations + +echo +echo "Translation stats:" +find . -name \*.po -print -execdir msgfmt --statistics messages.po \;