Script for updating translations (#1030)

Script for updating translation strings and print stats
This commit is contained in:
Daniel Markstedt 2022-12-11 11:05:05 -08:00 committed by GitHub
parent 0128660d40
commit 66a905f1d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -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 $ 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. 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. Then edit the updated messages.po file for your language. Make sure to update fuzzy strings and translate new ones.

View File

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