source: apps/routerconsole/java/bmsg.sh @ b4615ed

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