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

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

tag and script fixups

  • Property mode set to 100755
File size: 2.0 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 strings -name *.java -newer $i > $TMPFILE
19        if [ -s build/obj/net/i2p/router/web/messages_$LG.class -a \
20             build/obj/net/i2p/router/web/messages_$LG.class -nt $i -a \
21             ! -s $TMPFILE ]
22        then
23                continue
24        fi
25
26        echo "Generating ${CLASS}_$LG ResourceBundle..."
27
28        # extract strings from java and jsp files, and update messages.po files
29        # translate calls must be one of the forms:
30        # _("foo")
31        # _x("foo")
32        # intl._("foo")
33        # intl.title("foo")
34        # handler._("foo")
35        # formhandler._("foo")
36        # net.i2p.router.web.Messages.getString("foo")
37        # In a jsp, you must use a helper or handler that has the context set.
38        # To start a new translation, copy the header from an old translation to the new .po file,
39        # then ant distclean updater.
40        find src ../jsp/WEB-INF strings -name *.java > $TMPFILE
41        xgettext -f $TMPFILE -F -L java \
42                 --keyword=_ --keyword=_x --keyword=intl._ --keyword=intl.title \
43                 --keyword=handler._ --keyword=formhandler._ \
44                 --keyword=net.i2p.router.web.Messages.getString \
45                 -o ${i}t
46        if [ $? -ne 0 ]
47        then
48                echo 'Warning - xgettext failed, not updating translations'
49                rm -f ${i}t
50                break
51        fi
52        msgmerge -U --backup=none $i ${i}t
53        if [ $? -ne 0 ]
54        then
55                echo 'Warning - msgmerge failed, not updating translations'
56                rm -f ${i}t
57                break
58        fi
59        rm -f ${i}t
60        # so we don't do this again
61        touch $i
62
63        # convert to class files in build/obj
64        msgfmt --java -r $CLASS -l $LG -d build/obj $i
65        if [ $? -ne 0 ]
66        then
67                echo 'Warning - msgfmt failed, not updating translations'
68                break
69        fi
70done
71rm -f $TMPFILE
72# todo: return failure
73exit 0
Note: See TracBrowser for help on using the repository browser.