diff --git a/apps/routerconsole/java/build.xml b/apps/routerconsole/java/build.xml index f77a14387..f804d2fba 100644 --- a/apps/routerconsole/java/build.xml +++ b/apps/routerconsole/java/build.xml @@ -73,6 +73,15 @@ + + + + + + + @@ -115,6 +124,7 @@ @@ -133,10 +143,13 @@ + + diff --git a/apps/routerconsole/java/bundle-messages.sh b/apps/routerconsole/java/bundle-messages.sh new file mode 100755 index 000000000..6b2fe8cec --- /dev/null +++ b/apps/routerconsole/java/bundle-messages.sh @@ -0,0 +1,51 @@ +# +# 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 diff --git a/apps/routerconsole/java/src/net/i2p/router/web/CSSHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/CSSHelper.java index a2f3341f9..d12259e95 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/CSSHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/CSSHelper.java @@ -22,4 +22,10 @@ public class CSSHelper extends HelperBase { } return url; } + + /** change default language for the router but don't save it */ + public void setLang(String lang) { + if (lang != null && lang.length() > 0) + _context.router().setConfigSetting(Messages.PROP_LANG, lang); + } } diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHelper.java index 82d8461f1..164ac8df2 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigUpdateHelper.java @@ -87,7 +87,7 @@ public class ConfigUpdateHelper extends HelperBase { buf.append(""> Refresh frequency: - Update policy: + <%=formhandler._("Update policy")%>: Update through the eepProxy? diff --git a/apps/routerconsole/jsp/css.jsp b/apps/routerconsole/jsp/css.jsp index ed8675030..865e90723 100644 --- a/apps/routerconsole/jsp/css.jsp +++ b/apps/routerconsole/jsp/css.jsp @@ -25,5 +25,8 @@ " /> +<% + cssHelper.setLang(request.getParameter("lang")); +%> console.css" rel="stylesheet" type="text/css"> diff --git a/apps/routerconsole/jsp/index.jsp b/apps/routerconsole/jsp/index.jsp index b14f8e352..d2ce8ffc2 100644 --- a/apps/routerconsole/jsp/index.jsp +++ b/apps/routerconsole/jsp/index.jsp @@ -29,5 +29,6 @@ if (System.getProperty("router.consoleNonce") == null) { " /> + " /> diff --git a/apps/routerconsole/locale/messages_de.po b/apps/routerconsole/locale/messages_de.po new file mode 100644 index 000000000..5293b999f --- /dev/null +++ b/apps/routerconsole/locale/messages_de.po @@ -0,0 +1,25 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2009-10-18 10:03-0400\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:441 +msgid "Update policy" +msgstr "Update policy in german foobarbaz" + +#: src/net/i2p/router/web/ConfigUpdateHelper.java:90 +msgid "Notify only" +msgstr "Notify only in german" diff --git a/apps/routerconsole/locale/messages_zh.po b/apps/routerconsole/locale/messages_zh.po new file mode 100644 index 000000000..9e8818730 --- /dev/null +++ b/apps/routerconsole/locale/messages_zh.po @@ -0,0 +1,25 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2009-10-18 10:03-0400\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:441 +msgid "Update policy" +msgstr "" + +#: src/net/i2p/router/web/ConfigUpdateHelper.java:90 +msgid "Notify only" +msgstr ""