diff --git a/apps/i2psnark/java/bmsg.sh b/apps/i2psnark/java/bmsg.sh
new file mode 100644
index 0000000000..b9d294b323
--- /dev/null
+++ b/apps/i2psnark/java/bmsg.sh
@@ -0,0 +1,17 @@
+#
+# Update messages_xx.po and messages_xx.class files,
+# from both java and jsp sources.
+# Requires installed programs xgettext, msgfmt, msgmerge, and find.
+# zzz - public domain
+#
+
+## launching sh.exe with -login parameter will open a shell with the current path always pointing to \bin\
+## need to cd into our orignal path - where we call sh.exe from.
+
+cd $CALLFROM
+## echo $PWD
+
+## except this everything is the same with bundle-message.sh
+## walking - public domain :-D
+
+source bundle-messages.sh $PARAS
\ No newline at end of file
diff --git a/apps/i2psnark/java/build.xml b/apps/i2psnark/java/build.xml
index 59f0421e70..bcafb362e8 100644
--- a/apps/i2psnark/java/build.xml
+++ b/apps/i2psnark/java/build.xml
@@ -36,7 +36,7 @@
-
+
@@ -57,6 +57,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/i2psnark/java/bundle-messages.bat b/apps/i2psnark/java/bundle-messages.bat
new file mode 100644
index 0000000000..90feca972a
--- /dev/null
+++ b/apps/i2psnark/java/bundle-messages.bat
@@ -0,0 +1,26 @@
+@echo off
+set Callfrom=%cd%
+set Paras=%1
+
+rem before calling make sure you have msys and mingw 's "bin" path
+rem in your current searching path
+rem type "set path" to check
+if not exist ..\locale\*.only goto updateALL
+
+rem put a messages_xx.only(eg messages_zh.only) into locale folder
+rem this script will only touch the po file(eg zh) you specified, leaving other po files untact.
+
+for %%i in (..\locale\*.only) do set PO=%%~ni
+echo [Notice] Yu choose to Ony update the choosen file: %PO%.po
+for %%i in (..\locale\*.po) do if not %%~ni==%PO% ren %%i %%~ni.po-
+
+call sh --login %cd%\bmsg.sh
+
+for %%i in (..\locale\*.po-) do if not %%~ni==%PO% ren %%i %%~ni.po
+goto end
+
+:updateALL
+call sh --login %cd%\bmsg.sh
+
+:end
+echo End of Message Bundling
\ No newline at end of file
diff --git a/apps/i2psnark/java/bundle-messages.sh b/apps/i2psnark/java/bundle-messages.sh
new file mode 100755
index 0000000000..bd62ea9ee3
--- /dev/null
+++ b/apps/i2psnark/java/bundle-messages.sh
@@ -0,0 +1,85 @@
+#
+# Update messages_xx.po and messages_xx.class files,
+# from both java and jsp sources.
+# Requires installed programs xgettext, msgfmt, msgmerge, and find.
+#
+# usage:
+# bundle-messages.sh (generates the resource bundle from the .po file)
+# bundle-messages.sh -p (updates the .po file from the source tags, then generates the resource bundle)
+#
+# zzz - public domain
+#
+CLASS=org.klomp.snark.messages
+TMPFILE=build/javafiles.txt
+export TZ=UTC
+
+if [ "$1" = "-p" ]
+then
+ POUPDATE=1
+fi
+
+# add ../java/ so the refs will work in the po file
+JPATHS="../java/src"
+for i in ../locale/messages_*.po
+do
+ # get language
+ LG=${i#../locale/messages_}
+ LG=${LG%.po}
+
+ if [ "$POUPDATE" = "1" ]
+ then
+ # make list of java files newer than the .po file
+ find $JPATHS -name *.java -newer $i > $TMPFILE
+ fi
+
+ if [ -s build/obj/org/klomp/snark/messages_$LG.class -a \
+ build/obj/org/klomp/snark/messages_$LG.class -nt $i -a \
+ ! -s $TMPFILE ]
+ then
+ continue
+ fi
+
+ if [ "$POUPDATE" = "1" ]
+ then
+ echo "Updating the $i file from the tags..."
+ # extract strings from java and jsp files, and update messages.po files
+ # translate calls must be one of the forms:
+ # _("foo")
+ # _x("foo")
+ # To start a new translation, copy the header from an old translation to the new .po file,
+ # then ant distclean poupdate.
+ find $JPATHS -name *.java > $TMPFILE
+ xgettext -f $TMPFILE -F -L java --from-code=UTF-8 \
+ --keyword=_ --keyword=_x \
+ -o ${i}t
+ if [ $? -ne 0 ]
+ then
+ echo 'Warning - xgettext failed, not updating translations'
+ rm -f ${i}t
+ break
+ fi
+ msgmerge -U --backup=none $i ${i}t
+ if [ $? -ne 0 ]
+ then
+ echo 'Warning - msgmerge failed, not updating translations'
+ rm -f ${i}t
+ break
+ fi
+ rm -f ${i}t
+ # so we don't do this again
+ touch $i
+ fi
+
+ echo "Generating ${CLASS}_$LG ResourceBundle..."
+
+ # convert to class files in build/obj
+ msgfmt --java -r $CLASS -l $LG -d build/obj $i
+ if [ $? -ne 0 ]
+ then
+ echo 'Warning - msgfmt failed, not updating translations'
+ break
+ fi
+done
+rm -f $TMPFILE
+# todo: return failure
+exit 0
diff --git a/apps/i2psnark/java/src/org/klomp/snark/I2PSnarkUtil.java b/apps/i2psnark/java/src/org/klomp/snark/I2PSnarkUtil.java
index cbb1d17147..b40233fbb6 100644
--- a/apps/i2psnark/java/src/org/klomp/snark/I2PSnarkUtil.java
+++ b/apps/i2psnark/java/src/org/klomp/snark/I2PSnarkUtil.java
@@ -28,6 +28,7 @@ import net.i2p.util.FileUtil;
import net.i2p.util.Log;
import net.i2p.util.SimpleScheduler;
import net.i2p.util.SimpleTimer;
+import net.i2p.util.Translate;
/**
* I2P specific helpers for I2PSnark
@@ -402,4 +403,27 @@ public class I2PSnarkUtil {
break;
}
}
+
+ private static final String BUNDLE_NAME = "org.klomp.snark.messages";
+
+ /** lang in routerconsole.lang property, else current locale */
+ public String getString(String key) {
+ return Translate.getString(key, _context, BUNDLE_NAME);
+ }
+
+ /**
+ * translate a string with a parameter
+ * This is a lot more expensive than getString(s, ctx), so use sparingly.
+ *
+ * @param s string to be translated containing {0}
+ * The {0} will be replaced by the parameter.
+ * Single quotes must be doubled, i.e. ' -> '' in the string.
+ * @param o parameter, not translated.
+ * To tranlslate parameter also, use _("foo {0} bar", _("baz"))
+ * Do not double the single quotes in the parameter.
+ * Use autoboxing to call with ints, longs, floats, etc.
+ */
+ public String getString(String s, Object o) {
+ return Translate.getString(s, o, _context, BUNDLE_NAME);
+ }
}
diff --git a/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java b/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java
index 5beb0ae447..3198ca4b78 100644
--- a/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java
+++ b/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java
@@ -80,13 +80,23 @@ public class I2PSnarkServlet extends HttpServlet {
}
PrintWriter out = resp.getWriter();
- out.write(HEADER_BEGIN);
+ out.write("\n" +
+ "\n" +
+ "");
+ out.write(_("I2PSnark - Anonymous BitTorrent Client"));
+ out.write("\n");
+
// we want it to go to the base URI so we don't refresh with some funky action= value
out.write("\n");
out.write(HEADER);
out.write("");
out.write("