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

Last change on this file since e3d9452 was a0b4b7db, checked in by zzz <zzz@…>, 11 years ago
  • Console:
    • countries.txt: Convert to mixed case, include in update
    • netdb.jsp: Hide all routers by default, sort and tag country names
    • oldstats.jsp: Move to stats.jsp
    • profiles.jsp: Show new DBH times instead of counts
  • Profiles:
    • Track last good and bad lookup times and last good and bad store times, to prep for floodfill changes
    • Don't reset last-heard-about at router startup
  • Checklist and Android readme fixups
  • Property mode set to 100644
File size: 2.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#
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
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
35JPATHS="src ../jsp/WEB-INF strings $JFILE"
36for i in ../locale/messages_*.po
37do
38        # get language
39        LG=${i#../locale/messages_}
40        LG=${LG%.po}
41
42        # make list of java files newer than the .po file
43        find $JPATHS -name *.java -newer $i > $TMPFILE
44        if [ -s build/obj/net/i2p/router/web/messages_$LG.class -a \
45             build/obj/net/i2p/router/web/messages_$LG.class -nt $i -a \
46             ! -s $TMPFILE ]
47        then
48                continue
49        fi
50
51        echo "Generating ${CLASS}_$LG ResourceBundle..."
52
53        # extract strings from java and jsp files, and update messages.po files
54        # translate calls must be one of the forms:
55        # _("foo")
56        # _x("foo")
57        # intl._("foo")
58        # intl.title("foo")
59        # handler._("foo")
60        # formhandler._("foo")
61        # net.i2p.router.web.Messages.getString("foo")
62        # In a jsp, you must use a helper or handler that has the context set.
63        # To start a new translation, copy the header from an old translation to the new .po file,
64        # then ant distclean updater.
65        find $JPATHS -name *.java > $TMPFILE
66        xgettext -f $TMPFILE -F -L java --from-code=UTF-8 \
67                 --keyword=_ --keyword=_x --keyword=intl._ --keyword=intl.title \
68                 --keyword=handler._ --keyword=formhandler._ \
69                 --keyword=net.i2p.router.web.Messages.getString \
70                 -o ${i}t
71        if [ $? -ne 0 ]
72        then
73                echo 'Warning - xgettext failed, not updating translations'
74                rm -f ${i}t
75                break
76        fi
77        msgmerge -U --backup=none $i ${i}t
78        if [ $? -ne 0 ]
79        then
80                echo 'Warning - msgmerge failed, not updating translations'
81                rm -f ${i}t
82                break
83        fi
84        rm -f ${i}t
85        # so we don't do this again
86        touch $i
87
88        # convert to class files in build/obj
89        msgfmt --java -r $CLASS -l $LG -d build/obj $i
90        if [ $? -ne 0 ]
91        then
92                echo 'Warning - msgfmt failed, not updating translations'
93                break
94        fi
95done
96rm -f $TMPFILE
97# todo: return failure
98exit 0
Note: See TracBrowser for help on using the repository browser.