source: installer/resources/locale/bundle-messages.sh @ a13552dd

Last change on this file since a13552dd was a13552dd, checked in by dg2-new <dg2-new@…>, 6 years ago

Fix news (ant poupdate), typos in bundle-*

  • Property mode set to 100755
File size: 2.4 KB
Line 
1#!/bin/sh
2#
3# Update messages_xx.po and .mo files
4# Requires installed programs xgettext, msgfmt, msgmerge, and find.
5#
6# usage:
7#    bundle-messages.sh (generates the resource bundle from the .po file)
8#    bundle-messages.sh -p (updates the .po file from the source tags, then generates the resource bundle)
9#
10# zzz - public domain
11#
12TMPFILE=filelist.txt
13export TZ=UTC
14RC=0
15
16if [ "$1" = "-p" ]
17then
18        POUPDATE=1
19fi
20
21# on windows, one must specify the path of commnad find
22# since windows has its own version of find.
23if which find|grep -q -i windows ; then
24        export PATH=.:/bin:/usr/local/bin:$PATH
25fi
26# Fast mode - update ondemond
27# set LG2 to the language you need in environment variables to enable this
28
29JPATHS=".."
30for i in po/messages_*.po
31do
32        # get language
33        LG=${i#po/messages_}
34        LG=${LG%.po}
35
36        # skip, if specified
37        if [ $LG2 ]; then
38                [ $LG != $LG2 ] && continue || echo INFO: Language update is set to [$LG2] only.
39        fi
40
41        if [ "$POUPDATE" = "1" ]
42        then
43                # make list of java files newer than the .po file
44                find $JPATHS -maxdepth 1 -name i2prouter -newer $i > $TMPFILE
45        fi
46
47        if [ -s mo/$LG/LC_MESSAGES/i2prouter.mo -a \
48             mo/$LG/LC_MESSAGES/i2prouter.mo -nt $i -a \
49             ! -s $TMPFILE ]
50        then
51                continue
52        fi
53
54        if [ "$POUPDATE" = "1" ]
55        then
56                echo "Updating the $i file from the tags..."
57                # extract strings from files, and update messages.po files
58                find $JPATHS -maxdepth 1 -name i2prouter > $TMPFILE
59                xgettext -f $TMPFILE -F -L Shell --from-code=UTF-8 \
60                         -o ${i}t
61                if [ $? -ne 0 ]
62                then
63                        echo "ERROR - xgettext failed on ${i}, not updating translations"
64                        rm -f ${i}t
65                        RC=1
66                        break
67                fi
68                msgmerge -U --backup=none $i ${i}t
69                if [ $? -ne 0 ]
70                then
71                        echo "ERROR - msgmerge failed on ${i}, not updating translations"
72                        rm -f ${i}t
73                        RC=1
74                        break
75                fi
76                rm -f ${i}t
77                # so we don't do this again
78                touch $i
79        fi
80
81    if [ "$LG" != "en" ]
82    then
83        # only generate for non-source language
84        echo "Generating $LG ResourceBundle..."
85
86        # convert to class files in build/obj
87        mkdir -p mo/$LG/LC_MESSAGES
88        msgfmt --statistics -o mo/$LG/LC_MESSAGES/i2prouter.mo $i
89        if [ $? -ne 0 ]
90        then
91            echo "ERROR - msgfmt failed on ${i}, not updating translations"
92            # msgfmt leaves the class file there so the build would work the next time
93            rm -rf mo/$LG/LC_MESSAGES
94            RC=1
95            break
96        fi
97    fi
98done
99rm -f $TMPFILE
100exit $RC
Note: See TracBrowser for help on using the repository browser.