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

Last change on this file since 4497463 was 4497463, checked in by zzz <zzz@…>, 11 years ago
  • Router Console translation infrastructure:
    • Persistent lang setting with routerconsole.lang=xx
    • Loading any page with ?lang=xx changes the persistent setting
    • Add a custom Jetty handler to load foo_xx.jsp if it exists for language xx. This is for jsp files with lots of text in them. Otherwise use inline translate methods. Not for included jsps.
    • Add a script to create and update messages_xx.po translation files, and create ResourceBundles? from them
    • Add class to translate strings from cached ResourceBundles?
    • Add translate wrappers to HelperBase?, FormHandler?, and *Renderer, so calls can be made from both jsp and java files
    • Add two example translations on configupdate.jsp - one in the jsp itself and one in the helper.
    • This is for strings in routerconsole only. Will be expanded to other webapps and the router later.
  • Property mode set to 100755
File size: 1.4 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, and find.
5# zzz - public domain
6#
7CLASS=net.i2p.router.web.messages
8TMPFILE=build/javafiles.txt
9
10for i in ../locale/messages_*.po
11do
12        # get language
13        LG=${i#../locale/messages_}
14        LG=${LG%.po}
15
16        # make list of java files newer than the .po file
17        find src ../jsp/WEB-INF -name *.java -newer $i > $TMPFILE
18        if [ -s build/obj/net/i2p/router/web/messages_$LG.class -a ! -s $TMPFILE ]
19        then
20                continue
21        fi
22
23        echo "Generating ${CLASS}_$LG ResourceBundle..."
24
25        # extract strings from java and jsp files, and update messages.po files
26        # translate calls must be one of the forms:
27        # _("foo")
28        # cssHelper._("foo")
29        # handler._("foo")
30        # formhandler._("foo")
31        # In a jsp, you must use a helper or handler that has the context set.
32        # To start a new translation, copy the header from an old translation to the new .po file,
33        # then ant distclean updater.
34        xgettext -f build/javafiles.txt -F -L java --keyword=_ --keyword=cssHelper._ --keyword=handler._ --keyword=formhandler._ -o $i -j
35        if [ $? -ne 0 ]
36        then
37                echo 'Warning - xgettext failed, not updating translations'
38                break
39        fi
40
41        # convert to class files in build/obj
42        msgfmt --java -r $CLASS -l $LG -d build/obj $i
43        if [ $? -ne 0 ]
44        then
45                echo 'Warning - xgettext failed, not updating translations'
46                break
47        fi
48done
49rm -f $TMPFILE
50# todo: return failure
51exit 0
Note: See TracBrowser for help on using the repository browser.