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

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

add a common method for title formatting and translation

  • Property mode set to 100755
File size: 1.8 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        # cssHelper.title("foo")
31        # handler._("foo")
32        # formhandler._("foo")
33        # In a jsp, you must use a helper or handler that has the context set.
34        # To start a new translation, copy the header from an old translation to the new .po file,
35        # then ant distclean updater.
36        find src ../jsp/WEB-INF -name *.java > $TMPFILE
37        xgettext -f $TMPFILE -F -L java \
38                 --keyword=_ --keyword=cssHelper._ --keyword=cssHelper.title --keyword=handler._ --keyword=formhandler._ \
39                 -o ${i}t
40        if [ $? -ne 0 ]
41        then
42                echo 'Warning - xgettext failed, not updating translations'
43                rm -f ${i}t
44                break
45        fi
46        msgmerge -U --backup=none $i ${i}t
47        if [ $? -ne 0 ]
48        then
49                echo 'Warning - msgmerge failed, not updating translations'
50                rm -f ${i}t
51                break
52        fi
53        rm -f ${i}t
54        # so we don't do this again
55        touch $i
56
57        # convert to class files in build/obj
58        msgfmt --java -r $CLASS -l $LG -d build/obj $i
59        if [ $? -ne 0 ]
60        then
61                echo 'Warning - xgettext failed, not updating translations'
62                break
63        fi
64done
65rm -f $TMPFILE
66# todo: return failure
67exit 0
Note: See TracBrowser for help on using the repository browser.