-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_po.sh
31 lines (26 loc) · 873 Bytes
/
make_po.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
domain_name="test" # Should match the "domain" used by the app
langs="en ja" # modify as desired
# Force an English LANG setting (to make MinGW's gettext utilities
# happy in non-english locales)
export LANG=en
# Create a list of all source files
find . -iname '*.py' > xgettext_sources.txt
# Extract the strings
mkdir -p po
template="po/${domain_name}.pot"
xgettext -L python -f xgettext_sources.txt -o "$template"
# Create/update the localized .po files
for lang in $langs; do
outfile="po/${lang}.po"
if [ -e "$outfile" ]; then
# File exists; back up the old file and replace with a new
# one.
msgmerge "$outfile" "$template" -o "$outfile.new"
mv "$outfile" "$outfile.old"
mv "$outfile.new" "$outfile"
else
# New file
msginit --locale="$lang" -i "$template" -o "$outfile"
fi
done