forked from st4lk/tornado_i18n_example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakemessages.sh
More file actions
executable file
·28 lines (28 loc) · 927 Bytes
/
makemessages.sh
File metadata and controls
executable file
·28 lines (28 loc) · 927 Bytes
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
#!/bin/bash
# get arguments and init variables
if [ "$#" -lt 1 ]; then
echo "Usage: $0 <locale> [optional: <domain_name>]"
exit 1
fi
locale=$1
domain="messages"
if [ ! -z "$2" ]; then
domain=$2
fi
locale_dir="locale/${locale}/LC_MESSAGES"
pot_file="locale/${domain}.pot"
po_file="${locale_dir}/${domain}.po"
# create folders if not exists
mkdir -p $locale_dir
# create .pot file
find . -iname "*.html" -o -iname "*.py" | xargs \
xgettext --output=${pot_file} --language=Python --from-code=UTF-8 \
--sort-by-file --keyword=_ --keyword=_:1,2 --keyword=pgettext:1c,2 \
--keyword=pgettext:1c,2,3 --keyword=_Q --keyword=_Q:1,2 --no-wrap
# init .po file, if it doesn't exist yet
if [ ! -f $po_file ]; then
msginit --input=${pot_file} --output-file=${po_file} --no-wrap --locale=${locale}
else
# update .po file
msgmerge --no-wrap --sort-by-file --output-file=${po_file} ${po_file} ${pot_file}
fi