forked from I2P_Developers/i2p.i2p
- 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.
52 lines
1.4 KiB
Bash
Executable File
52 lines
1.4 KiB
Bash
Executable File
#
|
|
# Update messages_xx.po and messages_xx.class files,
|
|
# from both java and jsp sources.
|
|
# Requires installed programs xgettext, msgfmt, and find.
|
|
# zzz - public domain
|
|
#
|
|
CLASS=net.i2p.router.web.messages
|
|
TMPFILE=build/javafiles.txt
|
|
|
|
for i in ../locale/messages_*.po
|
|
do
|
|
# get language
|
|
LG=${i#../locale/messages_}
|
|
LG=${LG%.po}
|
|
|
|
# make list of java files newer than the .po file
|
|
find src ../jsp/WEB-INF -name *.java -newer $i > $TMPFILE
|
|
if [ -s build/obj/net/i2p/router/web/messages_$LG.class -a ! -s $TMPFILE ]
|
|
then
|
|
continue
|
|
fi
|
|
|
|
echo "Generating ${CLASS}_$LG ResourceBundle..."
|
|
|
|
# extract strings from java and jsp files, and update messages.po files
|
|
# translate calls must be one of the forms:
|
|
# _("foo")
|
|
# cssHelper._("foo")
|
|
# handler._("foo")
|
|
# formhandler._("foo")
|
|
# In a jsp, you must use a helper or handler that has the context set.
|
|
# To start a new translation, copy the header from an old translation to the new .po file,
|
|
# then ant distclean updater.
|
|
xgettext -f build/javafiles.txt -F -L java --keyword=_ --keyword=cssHelper._ --keyword=handler._ --keyword=formhandler._ -o $i -j
|
|
if [ $? -ne 0 ]
|
|
then
|
|
echo 'Warning - xgettext failed, not updating translations'
|
|
break
|
|
fi
|
|
|
|
# convert to class files in build/obj
|
|
msgfmt --java -r $CLASS -l $LG -d build/obj $i
|
|
if [ $? -ne 0 ]
|
|
then
|
|
echo 'Warning - xgettext failed, not updating translations'
|
|
break
|
|
fi
|
|
done
|
|
rm -f $TMPFILE
|
|
# todo: return failure
|
|
exit 0
|