Initial code
[apps/native/ug-mobile-ap.git] / po / update-po.sh
1 #!/bin/sh
2
3 PACKAGE=ug-setting-mobile-ap-ug
4 SRCROOT=..
5 POTFILES=POTFILES.in
6
7 #ALL_LINGUAS= am az be ca cs da de el en_CA en_GB es et fi fr hr hu it ja ko lv mk ml ms nb ne nl pa pl pt pt_BR ru rw sk sl sr sr@Latn sv ta tr uk vi zh_CN zh_TW
8 ALL_LINGUAS="en_US en_GB ja ko zh_CN"
9
10 XGETTEXT=/usr/bin/xgettext
11 MSGMERGE=/usr/bin/msgmerge
12
13 echo -n "Make ${PACKAGE}.pot  "
14 if [ ! -e $POTFILES ] ; then
15         echo "$POTFILES not found"
16         exit 1
17 fi
18
19 $XGETTEXT --default-domain=${PACKAGE} --directory=${SRCROOT} \
20                 --add-comments --keyword=_ --keyword=N_ --files-from=$POTFILES
21 if [ $? -ne 0 ]; then
22         echo "error"
23         exit 1  
24 fi
25
26 if [ ! -f ${PACKAGE}.po ]; then
27         echo "No such file: ${PACKAGE}.po"
28         exit 1
29 fi
30
31 rm -f ${PACKAGE}.pot && mv ${PACKAGE}.po ${PACKAGE}.pot
32 echo "done"
33
34 for LANG in $ALL_LINGUAS; do 
35         echo "$LANG : "
36
37         if [ ! -e $LANG.po ] ; then
38                 sed 's/CHARSET/UTF-8/g' ${PACKAGE}.pot > ${LANG}.po
39                 echo "${LANG}.po created"
40         else
41                 if $MSGMERGE ${LANG}.po ${PACKAGE}.pot -o ${LANG}.new.po ; then
42                         if cmp ${LANG}.po ${LANG}.new.po > /dev/null 2>&1; then
43                                 rm -f ${LANG}.new.po
44                         else
45                                 if mv -f ${LANG}.new.po ${LANG}.po; then
46                                         echo "" 
47                                 else
48                                         echo "msgmerge for $LANG.po failed: cannot move $LANG.new.po to $LANG.po" 1>&2
49                                         rm -f ${LANG}.new.po
50                                         exit 1
51                                 fi
52                         fi
53                 else
54                         echo "msgmerge for $LANG failed!"
55                         rm -f ${LANG}.new.po
56                 fi
57         fi
58         echo ""
59 done
60