Added script to populate translated and contextualized strings if possible

This commit is contained in:
Eliot Berriot 2019-03-08 12:08:24 +01:00
parent 54f7cc6e39
commit 593a1fe53b
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
2 changed files with 103 additions and 0 deletions

View file

@ -0,0 +1,21 @@
#!/bin/bash -eu
# Typical use:
# cp -r locales old_locales
# ./scripts/i18n-extract.sh
# ./scripts/i18n-populate-contextualized-strings.sh old_locales locales
# Then review/commit the changes
old_locales_dir=$1
new_locales_dir=$2
locales=$(tail -n +2 src/locales.js | sed -e 's/export default //' | jq '.locales[].code' | xargs echo)
# Generate .po files for each available language.
echo $locales
for lang in $locales; do
echo "Fixing contexts for $lang"
old_po_file=$old_locales_dir/$lang/LC_MESSAGES/app.po
new_po_file=$new_locales_dir/$lang/LC_MESSAGES/app.po
python3 ./scripts/contextualize.py $old_po_file $new_po_file --no-dry-run
done;