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

Last change on this file since f61372b was 827a92e, checked in by walking <walking@…>, 11 years ago

bundle-messag windows hack

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