diff --git a/apps/desktopgui/TODO b/apps/desktopgui/TODO
index 0f5a5de4a..5f38de78a 100644
--- a/apps/desktopgui/TODO
+++ b/apps/desktopgui/TODO
@@ -1,7 +1,12 @@
HIGH PRIORITY:
- Allow desktopgui to start, stop and restart I2P. - DONE
- Correct logging system - DONE
-- Internationalisation
+- Internationalisation:
+ * Add strings
+ * Add Windows support
+ * Might need some kind of trigger to reload the menu (for live language switching)
+ * Language choice is not actually set as a parameter in I2P config?
+ As a result, desktopgui always starts with the default, unless you manually set the language.
- Modify installer to set I2P directory parameter; or use $I2P?
UNKNOWN:
- API to allow applications to add themselves to the menu?
diff --git a/apps/desktopgui/build.xml b/apps/desktopgui/build.xml
index 961088719..f8de80428 100644
--- a/apps/desktopgui/build.xml
+++ b/apps/desktopgui/build.xml
@@ -39,6 +39,13 @@
+
+
+
+
+
+
+
@@ -62,6 +69,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/desktopgui/bundle-messages.sh b/apps/desktopgui/bundle-messages.sh
new file mode 100644
index 000000000..4762e9a8b
--- /dev/null
+++ b/apps/desktopgui/bundle-messages.sh
@@ -0,0 +1,95 @@
+#
+# 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
+# Mathiasdm - modifications for desktopgui
+#
+CLASS=net.i2p.desktopgui.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="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
+
+ echo $LG
+ if [ -s build/net/i2p/desktopgui/messages_$LG.class -a \
+ build/net/i2p/desktopgui/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")
+ # intl._("foo")
+ # intl.title("foo")
+ # handler._("foo")
+ # formhandler._("foo")
+ # net.i2p.router.web.Messages.getString("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.
+ find $JPATHS -name *.java > $TMPFILE
+ xgettext -f $TMPFILE -F -L java --from-code=UTF-8 --add-comments\
+ --keyword=_ --keyword=_x --keyword=intl._ --keyword=intl.title \
+ --keyword=handler._ --keyword=formhandler._ \
+ --keyword=net.i2p.router.web.Messages.getString \
+ -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
+ msgfmt --java --statistics -r $CLASS -l $LG -d build $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/desktopgui/locale/messages_nl.po b/apps/desktopgui/locale/messages_nl.po
new file mode 100644
index 000000000..f994059d2
--- /dev/null
+++ b/apps/desktopgui/locale/messages_nl.po
@@ -0,0 +1,31 @@
+#: src/net/i2p/desktopgui/TrayManager.java:73
+msgid "Launch I2P Browser"
+msgstr "Start I2P Browser"
+
+#: src/net/i2p/desktopgui/TrayManager.java:99
+msgid "Browser not found"
+msgstr "Browser niet gevonden"
+
+#: src/net/i2p/desktopgui/TrayManager.java:100
+msgid "The default browser for your system was not found."
+msgstr "De standaard webbrowser voor je systeem werd niet gevonden."
+
+#: src/net/i2p/desktopgui/TrayManager.java:111
+msgid "Start I2P"
+msgstr "I2P starten"
+
+#: src/net/i2p/desktopgui/TrayManager.java:126
+msgid "I2P is starting!"
+msgstr "I2P is aan het starten!"
+
+#: src/net/i2p/desktopgui/TrayManager.java:126
+msgid "Starting"
+msgstr "Bezig met starten"
+
+#: src/net/i2p/desktopgui/TrayManager.java:140
+msgid "Restart I2P"
+msgstr "I2P herstarten"
+
+#: src/net/i2p/desktopgui/TrayManager.java:161
+msgid "Stop I2P"
+msgstr "I2P stoppen"
diff --git a/apps/desktopgui/src/net/i2p/desktopgui/Main.java b/apps/desktopgui/src/net/i2p/desktopgui/Main.java
index 997cde64d..540807ada 100644
--- a/apps/desktopgui/src/net/i2p/desktopgui/Main.java
+++ b/apps/desktopgui/src/net/i2p/desktopgui/Main.java
@@ -31,6 +31,7 @@ public class Main {
* Main method launching the application.
*/
public static void main(String[] args) {
+ System.setProperty("java.awt.headless", "false");
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException ex) {
diff --git a/apps/desktopgui/src/net/i2p/desktopgui/TrayManager.java b/apps/desktopgui/src/net/i2p/desktopgui/TrayManager.java
index 8aa4e65c6..3c5899944 100644
--- a/apps/desktopgui/src/net/i2p/desktopgui/TrayManager.java
+++ b/apps/desktopgui/src/net/i2p/desktopgui/TrayManager.java
@@ -18,6 +18,7 @@ import java.net.URL;
import javax.swing.SwingWorker;
+import net.i2p.desktopgui.i18n.DesktopguiTranslator;
import net.i2p.desktopgui.router.RouterManager;
import net.i2p.desktopgui.util.ConfigurationManager;
import net.i2p.util.Log;
@@ -69,7 +70,7 @@ public class TrayManager {
boolean inI2P = ConfigurationManager.getInstance().getBooleanConfiguration("startWithI2P", false);
PopupMenu popup = new PopupMenu();
- MenuItem browserLauncher = new MenuItem("Launch I2P Browser");
+ MenuItem browserLauncher = new MenuItem(_("Launch I2P Browser"));
browserLauncher.addActionListener(new ActionListener() {
@Override
@@ -95,8 +96,8 @@ public class TrayManager {
}
}
else {
- trayIcon.displayMessage("Browser not found",
- "The default browser for your system was not found.",
+ trayIcon.displayMessage(_("Browser not found"),
+ _("The default browser for your system was not found."),
TrayIcon.MessageType.WARNING);
}
}
@@ -107,7 +108,7 @@ public class TrayManager {
});
popup.add(browserLauncher);
popup.addSeparator();
- MenuItem startItem = new MenuItem("Start I2P");
+ MenuItem startItem = new MenuItem(_("Start I2P"));
startItem.addActionListener(new ActionListener() {
@Override
@@ -122,7 +123,7 @@ public class TrayManager {
@Override
protected void done() {
- trayIcon.displayMessage("Starting", "I2P is starting!", TrayIcon.MessageType.INFO);
+ trayIcon.displayMessage(_("Starting"), _("I2P is starting!"), TrayIcon.MessageType.INFO);
//Hide the tray icon.
//We cannot stop the desktopgui program entirely,
//since that risks killing the I2P process as well.
@@ -136,7 +137,7 @@ public class TrayManager {
if(!inI2P) {
popup.add(startItem);
}
- MenuItem restartItem = new MenuItem("Restart I2P");
+ MenuItem restartItem = new MenuItem(_("Restart I2P"));
restartItem.addActionListener(new ActionListener() {
@Override
@@ -157,7 +158,7 @@ public class TrayManager {
if(inI2P) {
popup.add(restartItem);
}
- MenuItem stopItem = new MenuItem("Stop I2P");
+ MenuItem stopItem = new MenuItem(_("Stop I2P"));
stopItem.addActionListener(new ActionListener() {
@Override
@@ -190,4 +191,8 @@ public class TrayManager {
Image image = Toolkit.getDefaultToolkit().getImage(url);
return image;
}
+
+ private static String _(String s) {
+ return DesktopguiTranslator._(s);
+ }
}
diff --git a/apps/desktopgui/src/net/i2p/desktopgui/i18n/DesktopguiTranslator.java b/apps/desktopgui/src/net/i2p/desktopgui/i18n/DesktopguiTranslator.java
new file mode 100644
index 000000000..e6b091eb0
--- /dev/null
+++ b/apps/desktopgui/src/net/i2p/desktopgui/i18n/DesktopguiTranslator.java
@@ -0,0 +1,26 @@
+package net.i2p.desktopgui.i18n;
+
+import net.i2p.router.RouterContext;
+import net.i2p.util.Translate;
+
+public class DesktopguiTranslator {
+
+ private static final String BUNDLE_NAME = "net.i2p.desktopgui.messages";
+
+ private static RouterContext ctx;
+
+ private static RouterContext getRouterContext() {
+ if(ctx == null) {
+ ctx = RouterContext.listContexts().get(0);
+ }
+ return ctx;
+ }
+
+ public static String _(String s) {
+ return Translate.getString(s, getRouterContext(), BUNDLE_NAME);
+ }
+
+ public static String _(String s, Object o) {
+ return Translate.getString(s, o, getRouterContext(), BUNDLE_NAME);
+ }
+}
diff --git a/apps/desktopgui/src/net/i2p/desktopgui/package.html b/apps/desktopgui/src/net/i2p/desktopgui/package.html
new file mode 100644
index 000000000..ac1c91503
--- /dev/null
+++ b/apps/desktopgui/src/net/i2p/desktopgui/package.html
@@ -0,0 +1,5 @@
+
+
+ Desktopgui is a graphical interface to I2P that allows managing the lifecycle of I2P from the system tray.
+
+
diff --git a/apps/desktopgui/src/net/i2p/desktopgui/router/RouterManager.java b/apps/desktopgui/src/net/i2p/desktopgui/router/RouterManager.java
index 5a6001742..d838eef27 100644
--- a/apps/desktopgui/src/net/i2p/desktopgui/router/RouterManager.java
+++ b/apps/desktopgui/src/net/i2p/desktopgui/router/RouterManager.java
@@ -2,6 +2,7 @@ package net.i2p.desktopgui.router;
import java.io.IOException;
+import net.i2p.desktopgui.i18n.DesktopguiTranslator;
import net.i2p.desktopgui.util.ConfigurationManager;
import net.i2p.router.Router;
import net.i2p.router.RouterContext;
@@ -56,4 +57,8 @@ public class RouterManager {
public static void shutDown() {
getRouter().shutdownGracefully();
}
+
+ private static String _(String s) {
+ return DesktopguiTranslator._(s);
+ }
}