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

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