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

Last change on this file since 6019cf81 was 6019cf81, checked in by zzz <zzz@…>, 11 years ago
  • Console:
    • Tag tunnel status
  • Property mode set to 100755
File size: 2.7 KB
RevLine 
[4497463]1#
2# Update messages_xx.po and messages_xx.class files,
3# from both java and jsp sources.
[cf10451d]4# Requires installed programs xgettext, msgfmt, msgmerge, and find.
[4497463]5# zzz - public domain
6#
7CLASS=net.i2p.router.web.messages
8TMPFILE=build/javafiles.txt
[cf10451d]9export TZ=UTC
[4497463]10
[a0b4b7db]11#
12# generate strings/Countries.java from ../../../installer/resources/countries.txt
13#
14CFILE=../../../installer/resources/countries.txt
15JFILE=build/Countries.java
16if [ $CFILE -nt $JFILE -o ! -s $JFILE ]
17then
18        mkdir -p build
19        echo '// Automatically generated pseudo-java for xgettext - do not edit' > $JFILE
20        echo '// Translators may wish to translate a few of these, do not bother to translate all of them!!' >> $JFILE
21        sed 's/..,\(..*\)/_("\1");/' $CFILE >> $JFILE
22fi
23
[6019cf81]24# list specific files in router/ here, so we don't scan the whole tree
25ROUTERFILES="\
26   ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java \
27   ../../../router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java"
28JPATHS="src ../jsp/WEB-INF strings $JFILE $ROUTERFILES"
[4497463]29for i in ../locale/messages_*.po
30do
31        # get language
32        LG=${i#../locale/messages_}
33        LG=${LG%.po}
34
35        # make list of java files newer than the .po file
[a0b4b7db]36        find $JPATHS -name *.java -newer $i > $TMPFILE
[b4d83b1]37        if [ -s build/obj/net/i2p/router/web/messages_$LG.class -a \
38             build/obj/net/i2p/router/web/messages_$LG.class -nt $i -a \
39             ! -s $TMPFILE ]
[4497463]40        then
41                continue
42        fi
43
44        echo "Generating ${CLASS}_$LG ResourceBundle..."
45
46        # extract strings from java and jsp files, and update messages.po files
47        # translate calls must be one of the forms:
48        # _("foo")
[0c74e64]49        # _x("foo")
[a5cd0bd]50        # intl._("foo")
51        # intl.title("foo")
[4497463]52        # handler._("foo")
53        # formhandler._("foo")
[a2d90ee]54        # net.i2p.router.web.Messages.getString("foo")
[4497463]55        # In a jsp, you must use a helper or handler that has the context set.
56        # To start a new translation, copy the header from an old translation to the new .po file,
57        # then ant distclean updater.
[a0b4b7db]58        find $JPATHS -name *.java > $TMPFILE
[625d76b]59        xgettext -f $TMPFILE -F -L java --from-code=UTF-8 \
[a5cd0bd]60                 --keyword=_ --keyword=_x --keyword=intl._ --keyword=intl.title \
[0c74e64]61                 --keyword=handler._ --keyword=formhandler._ \
[a2d90ee]62                 --keyword=net.i2p.router.web.Messages.getString \
[45a59f00]63                 -o ${i}t
[4497463]64        if [ $? -ne 0 ]
65        then
66                echo 'Warning - xgettext failed, not updating translations'
[cf10451d]67                rm -f ${i}t
[4497463]68                break
69        fi
[cf10451d]70        msgmerge -U --backup=none $i ${i}t
71        if [ $? -ne 0 ]
72        then
73                echo 'Warning - msgmerge failed, not updating translations'
74                rm -f ${i}t
75                break
76        fi
77        rm -f ${i}t
78        # so we don't do this again
79        touch $i
[4497463]80
81        # convert to class files in build/obj
82        msgfmt --java -r $CLASS -l $LG -d build/obj $i
83        if [ $? -ne 0 ]
84        then
[a2d90ee]85                echo 'Warning - msgfmt failed, not updating translations'
[4497463]86                break
87        fi
88done
89rm -f $TMPFILE
90# todo: return failure
91exit 0
Note: See TracBrowser for help on using the repository browser.