-
Notifications
You must be signed in to change notification settings - Fork 0
/
i18nize.in
51 lines (41 loc) · 1.3 KB
/
i18nize.in
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
#
# Shell script to manage .po files.
#
# Run this file in the folder main __init__.py of product
#
# E.g. if your product is yourproduct.name
# you run this file in yourproduct.name/yourproduct/name
#
#
# Copyright 2009 Twinapex Research http://www.twinapex.com
# modified 2011 bei Klein & Partner KG - BlueDynamics Alliance
#
# Assume the product name is the current folder name
CURRENT_PATH=${:packagepath}
CATALOGNAME="${:domain}"
DUDE="${buildout:bin-directory}/i18ndude"
# List of languages
LANGUAGES="${:languages}"
# Create locales folder structure for languages
install -d locales
for lang in $LANGUAGES; do
install -d $CURRENT_PATH/locales/$lang/LC_MESSAGES
done
# Rebuild .pot
$DUDE rebuild-pot --pot $CURRENT_PATH/locales/$CATALOGNAME.pot --create $CATALOGNAME $CURRENT_PATH
# Compile po files
for lang in $(find $CURRENT_PATH/locales -mindepth 1 -maxdepth 1 -type d); do
if test -d $lang/LC_MESSAGES; then
PO=$lang/LC_MESSAGES/${dollar}{CATALOGNAME}.po
# Create po file if not exists
touch $PO
# Sync po file
echo "Syncing $PO"
$DUDE sync --pot $CURRENT_PATH/locales/$CATALOGNAME.pot $PO
# Compile .po to .mo
MO=$lang/LC_MESSAGES/${dollar}{CATALOGNAME}.mo
echo "Compiling $MO"
msgfmt -o $MO $PO
fi
done