forked from Cimbali/pympress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gettext.sh
executable file
·35 lines (27 loc) · 1.26 KB
/
gettext.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
32
33
34
#!/usr/bin/env bash
p=`realpath $0`
cd `dirname $p`
pot=pympress/share/locale/pympress.pot
translated=`ls pympress/share/locale/*/*.po`
version=`git describe --tags --abbrev=0`
opts="--no-location --no-wrap --sort-output"
pkg="--package-name=Pympress --package-version=${version} --msgid-bugs-address=me@cimba.li"
pkg="--omit-header" # Don't re-output headers as we update files
xgettext -d python $opts $pkg -L Python --from-code utf-8 --keyword=_ pympress/*.py
xgettext -d glade $opts $pkg -L Glade --keyword=translatable pympress/share/xml/*.glade
sed -i 's/CHARSET/UTF-8/g' python.po glade.po
msgcat $opts -t utf-8 -o temp.po $pot glade.po python.po && rm glade.po python.po && mv temp.po $pot
# Do some updates and remove comments
sed -i '/^msgid ""$/,$!d;/^"#-#-#-#-# \(glade\|pympress\)\.pot (Pympress v\S\+) #-#-#-#-#\\n"$/d' $pot
sed -i "/Project-Id-Version: Pympress v/s/v[.0-9a-z]\\+/${version}/" $pot $translated
# gettext doesn't like .pot, only .po
for t in $translated; do
printf "Updating %s: " "$t"
msgmerge -U $opts $t $pot
echo "Missing and fuzzy translations:"
sed -rn '1N;N;/^#, fuzzy/p;/\nmsgstr ""\n$/P;$s/\n(msgid ".*")\nmsgstr ""$/\1/p;D' $t
echo
echo after updating translations:
echo "msgfmt $t -fo `dirname $t`/LC_MESSAGES/pympress.mo"
echo
done