-
Notifications
You must be signed in to change notification settings - Fork 3
/
update-lang.sh
executable file
·30 lines (23 loc) · 976 Bytes
/
update-lang.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
#!/bin/bash
# this script:
# - updates the translation template file $MSGDIR/$DOMAIN.pot
# - updates .po files with new translatable strings in source code
# - compiles .po files to .mo files
# directory where localization files are placed
MSGDIR=messages
# textdomain
DOMAIN=graphcore
# find languages
LANGUAGES=$(cd messages; find -mindepth 1 -maxdepth 1 -type d -execdir basename '{}' ';')
SRC=$(find src -name '*.cpp'; find src -name '*.h')
TMPPOT=$(mktemp)
xgettext -d graphcore $SRC --keyword=_ -o - | sed "s/CHARSET/UTF-8/" > $TMPPOT &&
echo -n "merging new strings into template file $MSGDIR/$DOMAIN.pot " &&
msgmerge -U $MSGDIR/$DOMAIN.pot $TMPPOT &&
rm $TMPPOT &&
for LANG in $LANGUAGES; do
echo -n "merging new strings into $LANG " &&
msgmerge -U $MSGDIR/$LANG/LC_MESSAGES/$DOMAIN.po $MSGDIR/$DOMAIN.pot &&
echo generating binary message catalog for $LANG &&
msgfmt -c -v -o $MSGDIR/$LANG/LC_MESSAGES/$DOMAIN.mo $MSGDIR/$LANG/LC_MESSAGES/$DOMAIN.po
done