forked from I2P_Developers/i2p.i2p
Added translation support + first language (nl).
This commit is contained in:
@@ -1,7 +1,12 @@
|
|||||||
HIGH PRIORITY:
|
HIGH PRIORITY:
|
||||||
- Allow desktopgui to start, stop and restart I2P. - DONE
|
- Allow desktopgui to start, stop and restart I2P. - DONE
|
||||||
- Correct logging system - 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?
|
- Modify installer to set I2P directory parameter; or use $I2P?
|
||||||
UNKNOWN:
|
UNKNOWN:
|
||||||
- API to allow applications to add themselves to the menu?
|
- API to allow applications to add themselves to the menu?
|
||||||
|
@@ -39,6 +39,13 @@
|
|||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="jar" depends="compile">
|
<target name="jar" depends="compile">
|
||||||
|
<exec executable="sh" osfamily="unix" failifexecutionfails="true" >
|
||||||
|
<arg value="./bundle-messages.sh" />
|
||||||
|
</exec>
|
||||||
|
<exec executable="sh" osfamily="mac" failifexecutionfails="true" >
|
||||||
|
<arg value="./bundle-messages.sh" />
|
||||||
|
</exec>
|
||||||
|
|
||||||
<jar basedir="${build}" destfile="${dist}/${jar}">
|
<jar basedir="${build}" destfile="${dist}/${jar}">
|
||||||
<manifest>
|
<manifest>
|
||||||
<attribute name="Main-Class" value="net.i2p.desktopgui.Main"/>
|
<attribute name="Main-Class" value="net.i2p.desktopgui.Main"/>
|
||||||
@@ -62,6 +69,17 @@
|
|||||||
</javadoc>
|
</javadoc>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
<target name="poupdate">
|
||||||
|
<exec executable="sh" osfamily="unix" failifexecutionfails="true" >
|
||||||
|
<arg value="./bundle-messages.sh" />
|
||||||
|
<arg value="-p" />
|
||||||
|
</exec>
|
||||||
|
<exec executable="sh" osfamily="mac" failifexecutionfails="true" >
|
||||||
|
<arg value="./bundle-messages.sh" />
|
||||||
|
<arg value="-p" />
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
<target name="dist" depends="jar" />
|
<target name="dist" depends="jar" />
|
||||||
<target name="all" depends="jar" />
|
<target name="all" depends="jar" />
|
||||||
</project>
|
</project>
|
||||||
|
95
apps/desktopgui/bundle-messages.sh
Normal file
95
apps/desktopgui/bundle-messages.sh
Normal file
@@ -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
|
31
apps/desktopgui/locale/messages_nl.po
Normal file
31
apps/desktopgui/locale/messages_nl.po
Normal file
@@ -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"
|
@@ -31,6 +31,7 @@ public class Main {
|
|||||||
* Main method launching the application.
|
* Main method launching the application.
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
System.setProperty("java.awt.headless", "false");
|
||||||
try {
|
try {
|
||||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException ex) {
|
||||||
|
@@ -18,6 +18,7 @@ import java.net.URL;
|
|||||||
|
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
|
|
||||||
|
import net.i2p.desktopgui.i18n.DesktopguiTranslator;
|
||||||
import net.i2p.desktopgui.router.RouterManager;
|
import net.i2p.desktopgui.router.RouterManager;
|
||||||
import net.i2p.desktopgui.util.ConfigurationManager;
|
import net.i2p.desktopgui.util.ConfigurationManager;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
@@ -69,7 +70,7 @@ public class TrayManager {
|
|||||||
boolean inI2P = ConfigurationManager.getInstance().getBooleanConfiguration("startWithI2P", false);
|
boolean inI2P = ConfigurationManager.getInstance().getBooleanConfiguration("startWithI2P", false);
|
||||||
|
|
||||||
PopupMenu popup = new PopupMenu();
|
PopupMenu popup = new PopupMenu();
|
||||||
MenuItem browserLauncher = new MenuItem("Launch I2P Browser");
|
MenuItem browserLauncher = new MenuItem(_("Launch I2P Browser"));
|
||||||
browserLauncher.addActionListener(new ActionListener() {
|
browserLauncher.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -95,8 +96,8 @@ public class TrayManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
trayIcon.displayMessage("Browser not found",
|
trayIcon.displayMessage(_("Browser not found"),
|
||||||
"The default browser for your system was not found.",
|
_("The default browser for your system was not found."),
|
||||||
TrayIcon.MessageType.WARNING);
|
TrayIcon.MessageType.WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,7 +108,7 @@ public class TrayManager {
|
|||||||
});
|
});
|
||||||
popup.add(browserLauncher);
|
popup.add(browserLauncher);
|
||||||
popup.addSeparator();
|
popup.addSeparator();
|
||||||
MenuItem startItem = new MenuItem("Start I2P");
|
MenuItem startItem = new MenuItem(_("Start I2P"));
|
||||||
startItem.addActionListener(new ActionListener() {
|
startItem.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -122,7 +123,7 @@ public class TrayManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void done() {
|
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.
|
//Hide the tray icon.
|
||||||
//We cannot stop the desktopgui program entirely,
|
//We cannot stop the desktopgui program entirely,
|
||||||
//since that risks killing the I2P process as well.
|
//since that risks killing the I2P process as well.
|
||||||
@@ -136,7 +137,7 @@ public class TrayManager {
|
|||||||
if(!inI2P) {
|
if(!inI2P) {
|
||||||
popup.add(startItem);
|
popup.add(startItem);
|
||||||
}
|
}
|
||||||
MenuItem restartItem = new MenuItem("Restart I2P");
|
MenuItem restartItem = new MenuItem(_("Restart I2P"));
|
||||||
restartItem.addActionListener(new ActionListener() {
|
restartItem.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -157,7 +158,7 @@ public class TrayManager {
|
|||||||
if(inI2P) {
|
if(inI2P) {
|
||||||
popup.add(restartItem);
|
popup.add(restartItem);
|
||||||
}
|
}
|
||||||
MenuItem stopItem = new MenuItem("Stop I2P");
|
MenuItem stopItem = new MenuItem(_("Stop I2P"));
|
||||||
stopItem.addActionListener(new ActionListener() {
|
stopItem.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -190,4 +191,8 @@ public class TrayManager {
|
|||||||
Image image = Toolkit.getDefaultToolkit().getImage(url);
|
Image image = Toolkit.getDefaultToolkit().getImage(url);
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String _(String s) {
|
||||||
|
return DesktopguiTranslator._(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
5
apps/desktopgui/src/net/i2p/desktopgui/package.html
Normal file
5
apps/desktopgui/src/net/i2p/desktopgui/package.html
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<p>Desktopgui is a graphical interface to I2P that allows managing the lifecycle of I2P from the system tray.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
@@ -2,6 +2,7 @@ package net.i2p.desktopgui.router;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import net.i2p.desktopgui.i18n.DesktopguiTranslator;
|
||||||
import net.i2p.desktopgui.util.ConfigurationManager;
|
import net.i2p.desktopgui.util.ConfigurationManager;
|
||||||
import net.i2p.router.Router;
|
import net.i2p.router.Router;
|
||||||
import net.i2p.router.RouterContext;
|
import net.i2p.router.RouterContext;
|
||||||
@@ -56,4 +57,8 @@ public class RouterManager {
|
|||||||
public static void shutDown() {
|
public static void shutDown() {
|
||||||
getRouter().shutdownGracefully();
|
getRouter().shutdownGracefully();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String _(String s) {
|
||||||
|
return DesktopguiTranslator._(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user