source: apps/routerconsole/java/bundle-messages.sh @ cf10451d

Last change on this file since cf10451d was cf10451d, checked in by zzz <zzz@…>, 11 years ago

po script update, dont include java files in war

  • Property mode set to 100755
File size: 1.7 KB
Line 
1#
2# Update messages_xx.po and messages_xx.class files,
3# from both java and jsp sources.
4# Requires installed programs xgettext, msgfmt, msgmerge, and find.
5# zzz - public domain
6#
7CLASS=net.i2p.router.web.messages
8TMPFILE=build/javafiles.txt
9export TZ=UTC
10
11for i in ../locale/messages_*.po
12do
13        # get language
14        LG=${i#../locale/messages_}
15        LG=${LG%.po}
16
17        # make list of java files newer than the .po file
18        find src ../jsp/WEB-INF -name *.java -newer $i > $TMPFILE
19        if [ -s build/obj/net/i2p/router/web/messages_$LG.class -a ! -s $TMPFILE ]
20        then
21                continue
22        fi
23
24        echo "Generating ${CLASS}_$LG ResourceBundle..."
25
26        # extract strings from java and jsp files, and update messages.po files
27        # translate calls must be one of the forms:
28        # _("foo")
29        # cssHelper._("foo")
30        # handler._("foo")
31        # formhandler._("foo")
32        # In a jsp, you must use a helper or handler that has the context set.
33        # To start a new translation, copy the header from an old translation to the new .po file,
34        # then ant distclean updater.
35        find src ../jsp/WEB-INF -name *.java > $TMPFILE
36        xgettext -f $TMPFILE -F -L java --keyword=_ --keyword=cssHelper._ --keyword=handler._ --keyword=formhandler._ -o ${i}t
37        if [ $? -ne 0 ]
38        then
39                echo 'Warning - xgettext failed, not updating translations'
40                rm -f ${i}t
41                break
42        fi
43        msgmerge -U --backup=none $i ${i}t
44        if [ $? -ne 0 ]
45        then
46                echo 'Warning - msgmerge failed, not updating translations'
47                rm -f ${i}t
48                break
49        fi
50        rm -f ${i}t
51        # so we don't do this again
52        touch $i
53
54        # convert to class files in build/obj
55        msgfmt --java -r $CLASS -l $LG -d build/obj $i
56        if [ $? -ne 0 ]
57        then
58                echo 'Warning - xgettext failed, not updating translations'
59                break
60        fi
61done
62rm -f $TMPFILE
63# todo: return failure
64exit 0
Note: See TracBrowser for help on using the repository browser.