summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Johnson <mjj29@hecate.matthew.ath.cx>2007-12-03 14:53:05 +0000
committerMatthew Johnson <mjj29@hecate.matthew.ath.cx>2007-12-03 14:53:05 +0000
commitdfebae02810a7be48c240bed7f8c9a29c85433e4 (patch)
tree2de866364e20dce88dbc841b46055fa37b5aa48d
parentcd6aaa426e629ebda85e63d7a5bcff440abab0b4 (diff)
add gettext localization
-rw-r--r--INSTALL1
-rw-r--r--Makefile15
-rw-r--r--changelog2
-rw-r--r--org/freedesktop/dbus/AbstractConnection.java45
-rw-r--r--org/freedesktop/dbus/ArrayFrob.java13
-rw-r--r--org/freedesktop/dbus/BusAddress.java6
-rw-r--r--org/freedesktop/dbus/DBusAsyncReply.java6
-rw-r--r--org/freedesktop/dbus/DBusConnection.java88
-rw-r--r--org/freedesktop/dbus/DBusMatchRule.java12
-rw-r--r--org/freedesktop/dbus/DBusSignal.java10
-rw-r--r--org/freedesktop/dbus/DirectConnection.java27
-rw-r--r--org/freedesktop/dbus/Error.java4
-rw-r--r--org/freedesktop/dbus/ExportedObject.java12
-rw-r--r--org/freedesktop/dbus/Gettext.java30
-rw-r--r--org/freedesktop/dbus/Marshalling.java34
-rw-r--r--org/freedesktop/dbus/Message.java15
-rw-r--r--org/freedesktop/dbus/MessageReader.java15
-rw-r--r--org/freedesktop/dbus/MethodCall.java4
-rw-r--r--org/freedesktop/dbus/RemoteInvocationHandler.java21
-rw-r--r--org/freedesktop/dbus/Transport.java17
-rw-r--r--org/freedesktop/dbus/UInt16.java6
-rw-r--r--org/freedesktop/dbus/UInt32.java6
-rw-r--r--org/freedesktop/dbus/UInt64.java22
-rw-r--r--org/freedesktop/dbus/Variant.java21
-rw-r--r--org/freedesktop/dbus/bin/CreateInterface.java21
-rw-r--r--org/freedesktop/dbus/bin/DBusDaemon.java15
-rw-r--r--org/freedesktop/dbus/viewer/DBusViewer.java11
-rw-r--r--org/freedesktop/dbus/viewer/FileSaver.java16
-rw-r--r--org/freedesktop/dbus/viewer/SaveFileAction.java6
-rw-r--r--org/freedesktop/dbus/viewer/TabbedSaveAction.java8
-rw-r--r--translations/en_GB.po209
31 files changed, 525 insertions, 193 deletions
diff --git a/INSTALL b/INSTALL
index 1b1d9c2..41fe343 100644
--- a/INSTALL
+++ b/INSTALL
@@ -9,6 +9,7 @@ To compile and install the library you will need:
A Java 1.5-compliant VM and Compiler (at time of writing
only the Sun VM and Compiler is known to work).
The unix socket, debug and hexdump libraries from http://www.matthew.ath.cx/projects/java/
+ GNU gettext
To build and install the documentation you will also need:
diff --git a/Makefile b/Makefile
index 94b4067..bae751b 100644
--- a/Makefile
+++ b/Makefile
@@ -14,6 +14,7 @@ JAVA?=java
JAVADOC?=javadoc
JAR?=jar
MAKE?=make
+MSGFMT?=msgfmt
# Program parameters
CPFLAG?=-classpath
@@ -43,7 +44,7 @@ DEBUG=disable
VERSION = $(shell sed -n '1s/.* \(.*\):/\1/p' changelog)
RELEASEVERSION = $(shell sed -n '/^Version/s/.* \(.*\):/\1/p' changelog | sed -n '2p')
-DISTFILES=dbus-java.tex Makefile org tmp-session.conf CreateInterface.sgml DBusDaemon.sgml ListDBus.sgml DBusViewer.sgml changelog AUTHORS COPYING README INSTALL CreateInterface.sh DBusDaemon.sh ListDBus.sh DBusViewer.sh DBusDaemon.bat CreateInterface.bat ListDBus.bat DBusViewer.bat compile.bat DBusCall.bat DBusCall.sh DBusCall.sgml
+DISTFILES=dbus-java.tex Makefile org tmp-session.conf CreateInterface.sgml DBusDaemon.sgml ListDBus.sgml DBusViewer.sgml changelog AUTHORS COPYING README INSTALL CreateInterface.sh DBusDaemon.sh ListDBus.sh DBusViewer.sh DBusDaemon.bat CreateInterface.bat ListDBus.bat DBusViewer.bat compile.bat DBusCall.bat DBusCall.sh DBusCall.sgml translations
all: libdbus-java-$(VERSION).jar dbus-java-viewer-$(VERSION).jar bin/DBusDaemon bin/ListDBus bin/CreateInterface bin/DBusViewer dbus-java-bin-$(VERSION).jar bin/DBusCall
@@ -69,14 +70,20 @@ binclasses: .binclasses
mkdir -p classes
$(JAVAC) -cp classes:$(CLASSPATH):${JAVAUNIXJARDIR}/unix.jar:${JAVAUNIXJARDIR}/debug-$(DEBUG).jar:${JAVAUNIXJARDIR}/hexdump.jar -d classes $(JCFLAGS) $(SRCDIR)/dbus/bin/*.java
touch .binclasses
-.classes: $(SRCDIR)/*.java $(SRCDIR)/dbus/*.java $(SRCDIR)/dbus/exceptions/*.java $(SRCDIR)/dbus/types/*.java
+.classes: $(SRCDIR)/*.java $(SRCDIR)/dbus/*.java $(SRCDIR)/dbus/exceptions/*.java $(SRCDIR)/dbus/types/*.java translations/*.po
mkdir -p classes
- $(JAVAC) -d classes -cp classes:${JAVAUNIXJARDIR}/unix.jar:${JAVAUNIXJARDIR}/debug-$(DEBUG).jar:${JAVAUNIXJARDIR}/hexdump.jar:$(CLASSPATH) $(JCFLAGS) $^
+ $(JAVAC) -d classes -cp classes:${JAVAUNIXJARDIR}/unix.jar:${JAVAUNIXJARDIR}/debug-$(DEBUG).jar:${JAVAUNIXJARDIR}/hexdump.jar:$(CLASSPATH) $(JCFLAGS) $(SRCDIR)/*.java $(SRCDIR)/dbus/*.java $(SRCDIR)/dbus/exceptions/*.java $(SRCDIR)/dbus/types/*.java
+ (cd translations; for i in *.po; do $(MSGFMT) --java2 -r dbusjava_localized -d ../classes -l $${i%.po} $$i; done)
+ $(MSGFMT) --java2 -r dbusjava_localized -d classes translations/en_GB.po
touch .classes
+translations/en_GB.po: $(SRCDIR)/*.java $(SRCDIR)/dbus/*.java $(SRCDIR)/dbus/exceptions/*.java $(SRCDIR)/dbus/types/*.java $(SRCDIR)/dbus/bin/*.java $(SRCDIR)/dbus/viewer/*.java
+ echo "#java-format" > $@
+ sed -n '/_(/s/.*_("\([^"]*\)").*/\1/p' $^ | sort -u | sed 's/\(.*\)/msgid "\1"\nmsgstr "\1"/' >> $@
+
libdbus-java-$(VERSION).jar: .classes
echo "Class-Path: ${JAVAUNIXJARDIR}/unix.jar ${JAVAUNIXJARDIR}/debug-$(DEBUG).jar" > Manifest
- (cd classes; $(JAR) -cfm ../$@ ../Manifest org/freedesktop/dbus/*.class org/freedesktop/*.class org/freedesktop/dbus/types/*.class org/freedesktop/dbus/exceptions/*.class)
+ (cd classes; $(JAR) -cfm ../$@ ../Manifest org/freedesktop/dbus/*.class org/freedesktop/*.class org/freedesktop/dbus/types/*.class org/freedesktop/dbus/exceptions/*.class *localized*class)
dbus-java-test-$(VERSION).jar: .testclasses
echo "Class-Path: ${JARPREFIX}/libdbus-java-$(VERSION).jar" > Manifest
(cd classes; $(JAR) -cfm ../$@ ../Manifest org/freedesktop/dbus/test/*.class)
diff --git a/changelog b/changelog
index 6a9c161..44b42d6 100644
--- a/changelog
+++ b/changelog
@@ -9,7 +9,7 @@ Version 2.4:
parent program (don't hold a strong reference).
* Add fallback objects---a single object can be called for any
object under a given path prefix.
-
+ * Add support for localization of strings via gettext
Version 2.3.2:
diff --git a/org/freedesktop/dbus/AbstractConnection.java b/org/freedesktop/dbus/AbstractConnection.java
index b1ea257..2952150 100644
--- a/org/freedesktop/dbus/AbstractConnection.java
+++ b/org/freedesktop/dbus/AbstractConnection.java
@@ -10,6 +10,8 @@
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
@@ -17,6 +19,9 @@ import java.lang.reflect.Type;
import java.io.File;
import java.io.IOException;
+import java.text.MessageFormat;
+import java.text.ParseException;
+
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
@@ -380,12 +385,12 @@ public abstract class AbstractConnection
public void exportObject(String objectpath, DBusInterface object) throws DBusException
{
if (null == objectpath || "".equals(objectpath))
- throw new DBusException("Must Specify an Object Path");
+ throw new DBusException(_("Must Specify an Object Path"));
if (!objectpath.matches(OBJECT_REGEX)||objectpath.length() > MAX_NAME_LENGTH)
- throw new DBusException("Invalid object path ("+objectpath+")");
+ throw new DBusException(_("Invalid object path: ")+objectpath);
synchronized (exportedObjects) {
if (null != exportedObjects.get(objectpath))
- throw new DBusException("Object already exported");
+ throw new DBusException(_("Object already exported"));
ExportedObject eo = new ExportedObject(object);
exportedObjects.put(objectpath, eo);
objectTree.add(objectpath, eo, eo.introspectiondata);
@@ -403,9 +408,9 @@ public abstract class AbstractConnection
public void addFallback(String objectprefix, DBusInterface object) throws DBusException
{
if (null == objectprefix || "".equals(objectprefix))
- throw new DBusException("Must Specify an Object Path");
+ throw new DBusException(_("Must Specify an Object Path"));
if (!objectprefix.matches(OBJECT_REGEX)||objectprefix.length() > MAX_NAME_LENGTH)
- throw new DBusException("Invalid object path ("+objectprefix+")");
+ throw new DBusException(_("Invalid object path: ")+objectprefix);
ExportedObject eo = new ExportedObject(object);
fallbackcontainer.add(objectprefix, eo);
}
@@ -468,7 +473,7 @@ public abstract class AbstractConnection
*/
public <T extends DBusSignal> void removeSigHandler(Class<T> type, DBusSigHandler<T> handler) throws DBusException
{
- if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException("Not A DBus Signal");
+ if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(_("Not A DBus Signal"));
removeSigHandler(new DBusMatchRule(type), handler);
}
/**
@@ -481,10 +486,10 @@ public abstract class AbstractConnection
*/
public <T extends DBusSignal> void removeSigHandler(Class<T> type, DBusInterface object, DBusSigHandler<T> handler) throws DBusException
{
- if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException("Not A DBus Signal");
+ if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(_("Not A DBus Signal"));
String objectpath = importedObjects.get(object).objectpath;
if (!objectpath.matches(OBJECT_REGEX)||objectpath.length() > MAX_NAME_LENGTH)
- throw new DBusException("Invalid object path ("+objectpath+")");
+ throw new DBusException(_("Invalid object path: ")+objectpath);
removeSigHandler(new DBusMatchRule(type, null, objectpath), handler);
}
@@ -499,7 +504,7 @@ public abstract class AbstractConnection
*/
public <T extends DBusSignal> void addSigHandler(Class<T> type, DBusSigHandler<T> handler) throws DBusException
{
- if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException("Not A DBus Signal");
+ if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(_("Not A DBus Signal"));
addSigHandler(new DBusMatchRule(type), handler);
}
/**
@@ -513,10 +518,10 @@ public abstract class AbstractConnection
*/
public <T extends DBusSignal> void addSigHandler(Class<T> type, DBusInterface object, DBusSigHandler<T> handler) throws DBusException
{
- if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException("Not A DBus Signal");
+ if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(_("Not A DBus Signal"));
String objectpath = importedObjects.get(object).objectpath;
if (!objectpath.matches(OBJECT_REGEX)||objectpath.length() > MAX_NAME_LENGTH)
- throw new DBusException("Invalid object path ("+objectpath+")");
+ throw new DBusException(_("Invalid object path: ")+objectpath);
addSigHandler(new DBusMatchRule(type, null, objectpath), handler);
}
@@ -700,7 +705,7 @@ public abstract class AbstractConnection
if (null == eo) {
try {
- queueOutgoing(new Error(m, new DBus.Error.UnknownObject(m.getPath()+" is not an object provided by this process.")));
+ queueOutgoing(new Error(m, new DBus.Error.UnknownObject(m.getPath()+_(" is not an object provided by this process."))));
} catch (DBusException DBe) {}
return;
}
@@ -713,7 +718,7 @@ public abstract class AbstractConnection
meth = eo.methods.get(new MethodTuple(m.getName(), m.getSig()));
if (null == meth) {
try {
- queueOutgoing(new Error(m, new DBus.Error.UnknownMethod("The method `"+m.getInterface()+"."+m.getName()+"' does not exist on this object.")));
+ queueOutgoing(new Error(m, new DBus.Error.UnknownMethod(MessageFormat.format(_("The method `{0}.{1}' does not exist on this object."), new Object[] { m.getInterface(), m.getName() }))));
} catch (DBusException DBe) {}
return;
}
@@ -742,7 +747,7 @@ public abstract class AbstractConnection
} catch (Exception e) {
if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
try {
- conn.queueOutgoing(new Error(m, new DBus.Error.UnknownMethod("Failure in de-serializing message ("+e+")")));
+ conn.queueOutgoing(new Error(m, new DBus.Error.UnknownMethod(_("Failure in de-serializing message: ")+e)));
} catch (DBusException DBe) {}
return;
}
@@ -784,7 +789,7 @@ public abstract class AbstractConnection
} catch (Throwable e) {
if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
try {
- conn.queueOutgoing(new Error(m, new DBusExecutionException("Error Executing Method "+m.getInterface()+"."+m.getName()+": "+e.getMessage())));
+ conn.queueOutgoing(new Error(m, new DBusExecutionException(MessageFormat.format(_("Error Executing Method {0}.{1}: {2}"), new Object[] { m.getInterface(), m.getName(), e.getMessage() }))));
} catch (DBusException DBe) {}
}
}
@@ -900,7 +905,7 @@ public abstract class AbstractConnection
} else
try {
- queueOutgoing(new Error(mr, new DBusExecutionException("Spurious reply. No message with the given serial id was awaiting a reply.")));
+ queueOutgoing(new Error(mr, new DBusExecutionException(_("Spurious reply. No message with the given serial id was awaiting a reply."))));
} catch (DBusException DBe) {}
}
protected void sendMessage(Message m)
@@ -912,7 +917,7 @@ public abstract class AbstractConnection
if (m instanceof MethodCall) {
if (0 == (m.getFlags() & Message.Flags.NO_REPLY_EXPECTED))
if (null == pendingCalls)
- ((MethodCall) m).setReply(new Error("org.freedesktop.DBus.Local", "org.freedesktop.DBus.Local.Disconnected", 0, "s", new Object[] { "Disconnected" }));
+ ((MethodCall) m).setReply(new Error("org.freedesktop.DBus.Local", "org.freedesktop.DBus.Local.Disconnected", 0, "s", new Object[] { _("Disconnected") }));
else synchronized (pendingCalls) {
pendingCalls.put(m.getSerial(),(MethodCall) m);
}
@@ -929,7 +934,7 @@ public abstract class AbstractConnection
else if (m instanceof MethodCall)
try {
if (Debug.debug) Debug.print(Debug.INFO, "Setting reply to "+m+" as an error");
- ((MethodCall)m).setReply(new Error(m, new DBusExecutionException("Message Failed to Send: "+e.getMessage())));
+ ((MethodCall)m).setReply(new Error(m, new DBusExecutionException(_("Message Failed to Send: ")+e.getMessage())));
} catch (DBusException DBe) {}
else if (m instanceof MethodReturn)
try {
@@ -944,7 +949,7 @@ public abstract class AbstractConnection
}
private Message readIncoming() throws DBusException
{
- if (null == transport) throw new NotConnected("No transport present");
+ if (null == transport) throw new NotConnected(_("No transport present"));
Message m = null;
try {
m = transport.min.readMessage();
@@ -956,5 +961,5 @@ public abstract class AbstractConnection
/**
* Returns the address this connection is connected to.
*/
- public BusAddress getAddress() { return new BusAddress(addr); }
+ public BusAddress getAddress() throws ParseException { return new BusAddress(addr); }
}
diff --git a/org/freedesktop/dbus/ArrayFrob.java b/org/freedesktop/dbus/ArrayFrob.java
index 6b4347e..4e63bca 100644
--- a/org/freedesktop/dbus/ArrayFrob.java
+++ b/org/freedesktop/dbus/ArrayFrob.java
@@ -10,9 +10,12 @@
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+
import java.lang.reflect.Array;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
@@ -46,10 +49,10 @@ class ArrayFrob
public static Object[] wrap(Object o) throws IllegalArgumentException
{
Class ac = o.getClass();
- if (!ac.isArray()) throw new IllegalArgumentException("Not an array");
+ if (!ac.isArray()) throw new IllegalArgumentException(_("Not an array"));
Class cc = ac.getComponentType();
Class ncc = primitiveToWrapper.get(cc);
- if (null == ncc) throw new IllegalArgumentException("Not a primitive type");
+ if (null == ncc) throw new IllegalArgumentException(_("Not a primitive type"));
Object[] ns = (Object[]) Array.newInstance(ncc, Array.getLength(o));
for (int i = 0; i < ns.length; i++)
ns[i] = Array.get(o, i);
@@ -60,7 +63,7 @@ class ArrayFrob
Class<? extends Object[]> ac = ns.getClass();
Class cc = ac.getComponentType();
Class ncc = wrapperToPrimitive.get(cc);
- if (null == ncc) throw new IllegalArgumentException("Not a wrapper type");
+ if (null == ncc) throw new IllegalArgumentException(_("Not a wrapper type"));
Object o = Array.newInstance(ncc, ns.length);
for (int i = 0; i < ns.length; i++)
Array.set(o, i, ns[i]);
@@ -73,7 +76,7 @@ class ArrayFrob
public static List listify(Object o) throws IllegalArgumentException
{
if (o instanceof Object[]) return listify((Object[]) o);
- if (!o.getClass().isArray()) throw new IllegalArgumentException("Not an array");
+ if (!o.getClass().isArray()) throw new IllegalArgumentException(_("Not an array"));
List<Object> l = new ArrayList<Object>(Array.getLength(o));
for (int i = 0; i < Array.getLength(o); i++)
l.add(Array.get(o, i));
@@ -156,7 +159,7 @@ class ArrayFrob
throw new IllegalArgumentException(e);
}
- throw new IllegalArgumentException("Not An Expected Convertion type from "+o.getClass()+" to "+c);
+ throw new IllegalArgumentException(MessageFormat.format(_("Not An Expected Convertion type from {0} to {1}"), new Object[] { o.getClass(), c}));
}
public static Object[] type(Object[] old, Class c)
{
diff --git a/org/freedesktop/dbus/BusAddress.java b/org/freedesktop/dbus/BusAddress.java
index 768f636..65673c7 100644
--- a/org/freedesktop/dbus/BusAddress.java
+++ b/org/freedesktop/dbus/BusAddress.java
@@ -9,6 +9,8 @@
Full licence texts are included in the COPYING file with this program.
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+import java.text.ParseException;
import java.util.Map;
import java.util.HashMap;
import cx.ath.matthew.debug.Debug;
@@ -17,10 +19,12 @@ public class BusAddress
{
private String type;
private Map<String,String> parameters;
- public BusAddress(String address)
+ public BusAddress(String address) throws ParseException
{
+ if (null == address || "".equals(address)) throw new ParseException(_("Bus address is blank"), 0);
if (Debug.debug) Debug.print(Debug.VERBOSE, "Parsing bus address: "+address);
String[] ss = address.split(":", 2);
+ if (ss.length < 2) throw new ParseException(_("Bus address is invalid: ")+address, 0);
type = ss[0];
if (Debug.debug) Debug.print(Debug.VERBOSE, "Transport type: "+type);
String[] ps = ss[1].split(",");
diff --git a/org/freedesktop/dbus/DBusAsyncReply.java b/org/freedesktop/dbus/DBusAsyncReply.java
index 9b38ab0..86a6087 100644
--- a/org/freedesktop/dbus/DBusAsyncReply.java
+++ b/org/freedesktop/dbus/DBusAsyncReply.java
@@ -10,6 +10,8 @@
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
@@ -95,12 +97,12 @@ public class DBusAsyncReply<ReturnType>
checkReply();
if (null != rval) return rval;
else if (null != error) throw error;
- else throw new NoReply("Async call has not had a reply");
+ else throw new NoReply(_("Async call has not had a reply"));
}
public String toString()
{
- return "Waiting for: "+mc;
+ return _("Waiting for: ")+mc;
}
Method getMethod() { return me; }
AbstractConnection getConnection() { return conn; }
diff --git a/org/freedesktop/dbus/DBusConnection.java b/org/freedesktop/dbus/DBusConnection.java
index bc2e6c9..ca15a97 100644
--- a/org/freedesktop/dbus/DBusConnection.java
+++ b/org/freedesktop/dbus/DBusConnection.java
@@ -10,6 +10,8 @@
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+
import java.lang.ref.WeakReference;
import java.lang.reflect.Proxy;
@@ -17,6 +19,9 @@ import java.lang.reflect.Type;
import java.io.IOException;
+import java.text.MessageFormat;
+import java.text.ParseException;
+
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -49,7 +54,7 @@ public class DBusConnection extends AbstractConnection
if (Debug.debug) Debug.print(Debug.WARN, "Handling Disconnected signal from bus");
try {
Error err = new Error(
- "org.freedesktop.DBus.Local" , "org.freedesktop.DBus.Local.Disconnected", 0, "s", new Object[] { "Disconnected" });
+ "org.freedesktop.DBus.Local" , "org.freedesktop.DBus.Local.Disconnected", 0, "s", new Object[] { _("Disconnected") });
if (null != pendingCalls) synchronized (pendingCalls) {
long[] set = pendingCalls.getKeys();
for (long l: set) if (-1 != l) {
@@ -125,10 +130,10 @@ public class DBusConnection extends AbstractConnection
break;
case SESSION:
s = System.getenv("DBUS_SESSION_BUS_ADDRESS");
- if (null == s) throw new DBusException("Cannot Resolve Session Bus Address");
+ if (null == s) throw new DBusException(_("Cannot Resolve Session Bus Address"));
break;
default:
- throw new DBusException("Invalid Bus Type: "+bustype);
+ throw new DBusException(_("Invalid Bus Type: ")+bustype);
}
DBusConnection c = conn.get(s);
if (Debug.debug) Debug.print(Debug.VERBOSE, "Getting bus connection for "+s+": "+c);
@@ -158,7 +163,10 @@ public class DBusConnection extends AbstractConnection
transport = new Transport(addr, AbstractConnection.TIMEOUT);
} catch (IOException IOe) {
if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, IOe);
- throw new DBusException("Failed to connect to bus "+IOe.getMessage());
+ throw new DBusException(_("Failed to connect to bus ")+IOe.getMessage());
+ } catch (ParseException Pe) {
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, Pe);
+ throw new DBusException(_("Failed to connect to bus ")+Pe.getMessage());
}
// start listening for calls
@@ -208,7 +216,7 @@ public class DBusConnection extends AbstractConnection
}
}
- if (ifcs.size() == 0) throw new DBusException("Could not find an interface to cast to");
+ if (ifcs.size() == 0) throw new DBusException(_("Could not find an interface to cast to"));
RemoteObject ro = new RemoteObject(source, path, null, false);
DBusInterface newi = (DBusInterface)
@@ -219,7 +227,7 @@ public class DBusConnection extends AbstractConnection
return newi;
} catch (Exception e) {
if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
- throw new DBusException("Failed to create proxy object for "+path+" exported by "+source+". Reason: "+e.getMessage());
+ throw new DBusException(MessageFormat.format(_("Failed to create proxy object for {0} exported by {1}. Reason: {2}"), new Object[] { path, source, e.getMessage() }));
}
}
@@ -234,7 +242,7 @@ public class DBusConnection extends AbstractConnection
o = null;
}
if (null != o) return o.object.get();
- if (null == source) throw new DBusException("Not an object exported by this connection and no remote specified");
+ if (null == source) throw new DBusException(_("Not an object exported by this connection and no remote specified"));
return dynamicProxy(source, path);
}
@@ -248,7 +256,7 @@ public class DBusConnection extends AbstractConnection
public void requestBusName(String busname) throws DBusException
{
if (!busname.matches(BUSNAME_REGEX)||busname.length() > MAX_NAME_LENGTH)
- throw new DBusException("Invalid bus name");
+ throw new DBusException(_("Invalid bus name"));
synchronized (this.busnames) {
UInt32 rv;
try {
@@ -261,8 +269,8 @@ public class DBusConnection extends AbstractConnection
}
switch (rv.intValue()) {
case DBus.DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER: break;
- case DBus.DBUS_REQUEST_NAME_REPLY_IN_QUEUE: throw new DBusException("Failed to register bus name");
- case DBus.DBUS_REQUEST_NAME_REPLY_EXISTS: throw new DBusException("Failed to register bus name");
+ case DBus.DBUS_REQUEST_NAME_REPLY_IN_QUEUE: throw new DBusException(_("Failed to register bus name"));
+ case DBus.DBUS_REQUEST_NAME_REPLY_EXISTS: throw new DBusException(_("Failed to register bus name"));
case DBus.DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER: break;
default: break;
}
@@ -311,11 +319,11 @@ public class DBusConnection extends AbstractConnection
*/
public DBusInterface getPeerRemoteObject(String busname, String objectpath) throws DBusException
{
- if (null == busname) throw new DBusException("Invalid bus name (null)");
+ if (null == busname) throw new DBusException(_("Invalid bus name: null"));
if ((!busname.matches(BUSNAME_REGEX) && !busname.matches(CONNID_REGEX))
|| busname.length() > MAX_NAME_LENGTH)
- throw new DBusException("Invalid bus name ("+busname+")");
+ throw new DBusException(_("Invalid bus name: ")+busname);
String unique = _dbus.GetNameOwner(busname);
@@ -344,15 +352,15 @@ public class DBusConnection extends AbstractConnection
*/
public DBusInterface getRemoteObject(String busname, String objectpath) throws DBusException
{
- if (null == busname) throw new DBusException("Invalid bus name (null)");
- if (null == objectpath) throw new DBusException("Invalid object path (null)");
+ if (null == busname) throw new DBusException(_("Invalid bus name: null"));
+ if (null == objectpath) throw new DBusException(_("Invalid object path: null"));
if ((!busname.matches(BUSNAME_REGEX) && !busname.matches(CONNID_REGEX))
|| busname.length() > MAX_NAME_LENGTH)
- throw new DBusException("Invalid bus name ("+busname+")");
+ throw new DBusException(_("Invalid bus name: ")+busname);
if (!objectpath.matches(OBJECT_REGEX) || objectpath.length() > MAX_NAME_LENGTH)
- throw new DBusException("Invalid object path ("+objectpath+")");
+ throw new DBusException(_("Invalid object path: ")+objectpath);
return dynamicProxy(busname, objectpath);
}
@@ -377,11 +385,11 @@ public class DBusConnection extends AbstractConnection
*/
public <I extends DBusInterface> I getPeerRemoteObject(String busname, String objectpath, Class<I> type, boolean autostart) throws DBusException
{
- if (null == busname) throw new DBusException("Invalid bus name (null)");
+ if (null == busname) throw new DBusException(_("Invalid bus name: null"));
if ((!busname.matches(BUSNAME_REGEX) && !busname.matches(CONNID_REGEX))
|| busname.length() > MAX_NAME_LENGTH)
- throw new DBusException("Invalid bus name ("+busname+")");
+ throw new DBusException(_("Invalid bus name: ")+busname);
String unique = _dbus.GetNameOwner(busname);
@@ -426,23 +434,23 @@ public class DBusConnection extends AbstractConnection
@SuppressWarnings("unchecked")
public <I extends DBusInterface> I getRemoteObject(String busname, String objectpath, Class<I> type, boolean autostart) throws DBusException
{
- if (null == busname) throw new DBusException("Invalid bus name (null)");
- if (null == objectpath) throw new DBusException("Invalid object path (null)");
- if (null == type) throw new ClassCastException("Not A DBus Interface");
+ if (null == busname) throw new DBusException(_("Invalid bus name: null"));
+ if (null == objectpath) throw new DBusException(_("Invalid object path: null"));
+ if (null == type) throw new ClassCastException(_("Not A DBus Interface"));
if ((!busname.matches(BUSNAME_REGEX) && !busname.matches(CONNID_REGEX))
|| busname.length() > MAX_NAME_LENGTH)
- throw new DBusException("Invalid bus name ("+busname+")");
+ throw new DBusException(_("Invalid bus name: ")+busname);
if (!objectpath.matches(OBJECT_REGEX) || objectpath.length() > MAX_NAME_LENGTH)
- throw new DBusException("Invalid object path ("+objectpath+")");
+ throw new DBusException(_("Invalid object path: ")+objectpath);
- if (!DBusInterface.class.isAssignableFrom(type)) throw new ClassCastException("Not A DBus Interface");
+ if (!DBusInterface.class.isAssignableFrom(type)) throw new ClassCastException(_("Not A DBus Interface"));
// don't let people import things which don't have a
// valid D-Bus interface name
if (type.getName().equals(type.getSimpleName()))
- throw new DBusException("DBusInterfaces cannot be declared outside a package");
+ throw new DBusException(_("DBusInterfaces cannot be declared outside a package"));
RemoteObject ro = new RemoteObject(busname, objectpath, type, autostart);
I i = (I) Proxy.newProxyInstance(type.getClassLoader(),
@@ -460,10 +468,10 @@ public class DBusConnection extends AbstractConnection
*/
public <T extends DBusSignal> void removeSigHandler(Class<T> type, String source, DBusSigHandler<T> handler) throws DBusException
{
- if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException("Not A DBus Signal");
- if (source.matches(BUSNAME_REGEX)) throw new DBusException("Cannot watch for signals based on well known bus name as source, only unique names.");
+ if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(_("Not A DBus Signal"));
+ if (source.matches(BUSNAME_REGEX)) throw new DBusException(_("Cannot watch for signals based on well known bus name as source, only unique names."));
if (!source.matches(CONNID_REGEX)||source.length() > MAX_NAME_LENGTH)
- throw new DBusException("Invalid bus name ("+source+")");
+ throw new DBusException(_("Invalid bus name: ")+source);
removeSigHandler(new DBusMatchRule(type, source, null), handler);
}
/**
@@ -477,13 +485,13 @@ public class DBusConnection extends AbstractConnection
*/
public <T extends DBusSignal> void removeSigHandler(Class<T> type, String source, DBusInterface object, DBusSigHandler<T> handler) throws DBusException
{
- if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException("Not A DBus Signal");
- if (source.matches(BUSNAME_REGEX)) throw new DBusException("Cannot watch for signals based on well known bus name as source, only unique names.");
+ if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(_("Not A DBus Signal"));
+ if (source.matches(BUSNAME_REGEX)) throw new DBusException(_("Cannot watch for signals based on well known bus name as source, only unique names."));
if (!source.matches(CONNID_REGEX)||source.length() > MAX_NAME_LENGTH)
- throw new DBusException("Invalid bus name ("+source+")");
+ throw new DBusException(_("Invalid bus name: ")+source);
String objectpath = importedObjects.get(object).objectpath;
if (!objectpath.matches(OBJECT_REGEX)||objectpath.length() > MAX_NAME_LENGTH)
- throw new DBusException("Invalid object path ("+objectpath+")");
+ throw new DBusException(_("Invalid object path: ")+objectpath);
removeSigHandler(new DBusMatchRule(type, source, objectpath), handler);
}
protected <T extends DBusSignal> void removeSigHandler(DBusMatchRule rule, DBusSigHandler<T> handler) throws DBusException
@@ -517,10 +525,10 @@ public class DBusConnection extends AbstractConnection
*/
public <T extends DBusSignal> void addSigHandler(Class<T> type, String source, DBusSigHandler<T> handler) throws DBusException
{
- if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException("Not A DBus Signal");
- if (source.matches(BUSNAME_REGEX)) throw new DBusException("Cannot watch for signals based on well known bus name as source, only unique names.");
+ if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(_("Not A DBus Signal"));
+ if (source.matches(BUSNAME_REGEX)) throw new DBusException(_("Cannot watch for signals based on well known bus name as source, only unique names."));
if (!source.matches(CONNID_REGEX)||source.length() > MAX_NAME_LENGTH)
- throw new DBusException("Invalid bus name ("+source+")");
+ throw new DBusException(_("Invalid bus name: ")+source);
addSigHandler(new DBusMatchRule(type, source, null), handler);
}
/**
@@ -535,13 +543,13 @@ public class DBusConnection extends AbstractConnection
*/
public <T extends DBusSignal> void addSigHandler(Class<T> type, String source, DBusInterface object, DBusSigHandler<T> handler) throws DBusException
{
- if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException("Not A DBus Signal");
- if (source.matches(BUSNAME_REGEX)) throw new DBusException("Cannot watch for signals based on well known bus name as source, only unique names.");
+ if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(_("Not A DBus Signal"));
+ if (source.matches(BUSNAME_REGEX)) throw new DBusException(_("Cannot watch for signals based on well known bus name as source, only unique names."));
if (!source.matches(CONNID_REGEX)||source.length() > MAX_NAME_LENGTH)
- throw new DBusException("Invalid bus name ("+source+")");
+ throw new DBusException(_("Invalid bus name: ")+source);
String objectpath = importedObjects.get(object).objectpath;
if (!objectpath.matches(OBJECT_REGEX)||objectpath.length() > MAX_NAME_LENGTH)
- throw new DBusException("Invalid object path ("+objectpath+")");
+ throw new DBusException(_("Invalid object path: ")+objectpath);
addSigHandler(new DBusMatchRule(type, source, objectpath), handler);
}
protected <T extends DBusSignal> void addSigHandler(DBusMatchRule rule, DBusSigHandler<T> handler) throws DBusException
@@ -576,7 +584,7 @@ public class DBusConnection extends AbstractConnection
// Set all pending messages to have an error.
try {
Error err = new Error(
- "org.freedesktop.DBus.Local" , "org.freedesktop.DBus.Local.Disconnected", 0, "s", new Object[] { "Disconnected" });
+ "org.freedesktop.DBus.Local" , "org.freedesktop.DBus.Local.Disconnected", 0, "s", new Object[] { _("Disconnected") });
synchronized (pendingCalls) {
long[] set = pendingCalls.getKeys();
for (long l: set) if (-1 != l) {
diff --git a/org/freedesktop/dbus/DBusMatchRule.java b/org/freedesktop/dbus/DBusMatchRule.java
index 3bd1d77..987c796 100644
--- a/org/freedesktop/dbus/DBusMatchRule.java
+++ b/org/freedesktop/dbus/DBusMatchRule.java
@@ -10,6 +10,8 @@
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+
import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.exceptions.DBusExecutionException;
@@ -69,7 +71,7 @@ public class DBusMatchRule
else
iface = AbstractConnection.dollar_pattern.matcher(c.getName()).replaceAll(".");
if (!iface.matches(".*\\..*"))
- throw new DBusException("DBusInterfaces must be defined in a package.");
+ throw new DBusException(_("DBusInterfaces must be defined in a package."));
member = null;
type = null;
}
@@ -80,7 +82,7 @@ public class DBusMatchRule
iface = AbstractConnection.dollar_pattern.matcher(c.getEnclosingClass().getName()).replaceAll(".");
// Don't export things which are invalid D-Bus interfaces
if (!iface.matches(".*\\..*"))
- throw new DBusException("DBusInterfaces must be defined in a package.");
+ throw new DBusException(_("DBusInterfaces must be defined in a package."));
if (c.isAnnotationPresent(DBusMemberName.class))
member = ((DBusMemberName) c.getAnnotation(DBusMemberName.class)).value();
else
@@ -93,7 +95,7 @@ public class DBusMatchRule
else
iface = AbstractConnection.dollar_pattern.matcher(c.getName()).replaceAll(".");
if (!iface.matches(".*\\..*"))
- throw new DBusException("DBusInterfaces must be defined in a package.");
+ throw new DBusException(_("DBusInterfaces must be defined in a package."));
member = null;
type = "error";
}
@@ -103,12 +105,12 @@ public class DBusMatchRule
else
iface = AbstractConnection.dollar_pattern.matcher(c.getClass().getName()).replaceAll(".");
if (!iface.matches(".*\\..*"))
- throw new DBusException("DBusInterfaces must be defined in a package.");
+ throw new DBusException(_("DBusInterfaces must be defined in a package."));
member = null;
type = "error";
}
else
- throw new DBusException("Invalid type for match rule ("+c+")");
+ throw new DBusException(_("Invalid type for match rule: ")+c);
}
public String toString()
{
diff --git a/org/freedesktop/dbus/DBusSignal.java b/org/freedesktop/dbus/DBusSignal.java
index 250b094..1bc9ace 100644
--- a/org/freedesktop/dbus/DBusSignal.java
+++ b/org/freedesktop/dbus/DBusSignal.java
@@ -10,6 +10,8 @@
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
@@ -31,7 +33,7 @@ public class DBusSignal extends Message
super(Message.Endian.BIG, Message.MessageType.SIGNAL, (byte) 0);
if (null == path || null == member || null == iface)
- throw new MessageFormatException("Must specify object path, interface and signal name to Signals.");
+ throw new MessageFormatException(_("Must specify object path, interface and signal name to Signals."));
headers.put(Message.HeaderField.PATH,path);
headers.put(Message.HeaderField.MEMBER,member);
headers.put(Message.HeaderField.INTERFACE,iface);
@@ -165,7 +167,7 @@ public class DBusSignal extends Message
{
super(Message.Endian.BIG, Message.MessageType.SIGNAL, (byte) 0);
- if (!objectpath.matches(AbstractConnection.OBJECT_REGEX)) throw new DBusException("Invalid object path ("+objectpath+")");
+ if (!objectpath.matches(AbstractConnection.OBJECT_REGEX)) throw new DBusException(_("Invalid object path: ")+objectpath);
Class tc = getClass();
String member;
@@ -178,7 +180,7 @@ public class DBusSignal extends Message
if (null == enc ||
!DBusInterface.class.isAssignableFrom(enc) ||
enc.getName().equals(enc.getSimpleName()))
- throw new DBusException("Signals must be declared as a member of a class implementing DBusInterface which is the member of a package.");
+ throw new DBusException(_("Signals must be declared as a member of a class implementing DBusInterface which is the member of a package."));
else
if (null != enc.getAnnotation(DBusInterfaceName.class))
iface = ((DBusInterfaceName) enc.getAnnotation(DBusInterfaceName.class)).value();
@@ -216,7 +218,7 @@ public class DBusSignal extends Message
setArgs(args);
} catch (Exception e) {
if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
- throw new DBusException("Failed to add signal parameters: "+e.getMessage());
+ throw new DBusException(_("Failed to add signal parameters: ")+e.getMessage());
}
}
diff --git a/org/freedesktop/dbus/DirectConnection.java b/org/freedesktop/dbus/DirectConnection.java
index 5254d54..bdcd6e9 100644
--- a/org/freedesktop/dbus/DirectConnection.java
+++ b/org/freedesktop/dbus/DirectConnection.java
@@ -10,11 +10,15 @@
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+
import java.lang.ref.WeakReference;
import java.lang.reflect.Proxy;
import java.io.File;
import java.io.IOException;
import java.net.ServerSocket;
+import java.text.MessageFormat;
+import java.text.ParseException;
import java.util.Random;
import java.util.Vector;
@@ -42,7 +46,10 @@ public class DirectConnection extends AbstractConnection
transport = new Transport(addr, AbstractConnection.TIMEOUT);
} catch (IOException IOe) {
if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, IOe);
- throw new DBusException("Failed to connect to bus "+IOe.getMessage());
+ throw new DBusException(_("Failed to connect to bus ")+IOe.getMessage());
+ } catch (ParseException Pe) {
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, Pe);
+ throw new DBusException(_("Failed to connect to bus ")+Pe.getMessage());
}
listen();
@@ -121,7 +128,7 @@ public class DirectConnection extends AbstractConnection
}
}
- if (ifcs.size() == 0) throw new DBusException("Could not find an interface to cast to");
+ if (ifcs.size() == 0) throw new DBusException(_("Could not find an interface to cast to"));
RemoteObject ro = new RemoteObject(null, path, null, false);
DBusInterface newi = (DBusInterface)
@@ -132,7 +139,7 @@ public class DirectConnection extends AbstractConnection
return newi;
} catch (Exception e) {
if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
- throw new DBusException("Failed to create proxy object for "+path+". Reason: "+e.getMessage());
+ throw new DBusException(MessageFormat.format(_("Failed to create proxy object for {0}; reason: {1}."), new Object[] { path, e.getMessage()}));
}
}
@@ -170,10 +177,10 @@ public class DirectConnection extends AbstractConnection
*/
public DBusInterface getRemoteObject(String objectpath) throws DBusException
{
- if (null == objectpath) throw new DBusException("Invalid object path (null)");
+ if (null == objectpath) throw new DBusException(_("Invalid object path: null"));
if (!objectpath.matches(OBJECT_REGEX) || objectpath.length() > MAX_NAME_LENGTH)
- throw new DBusException("Invalid object path ("+objectpath+")");
+ throw new DBusException(_("Invalid object path: ")+objectpath);
return dynamicProxy(objectpath);
}
@@ -192,18 +199,18 @@ public class DirectConnection extends AbstractConnection
*/
public DBusInterface getRemoteObject(String objectpath, Class<? extends DBusInterface> type) throws DBusException
{
- if (null == objectpath) throw new DBusException("Invalid object path (null)");
- if (null == type) throw new ClassCastException("Not A DBus Interface");
+ if (null == objectpath) throw new DBusException(_("Invalid object path: null"));
+ if (null == type) throw new ClassCastException(_("Not A DBus Interface"));
if (!objectpath.matches(OBJECT_REGEX) || objectpath.length() > MAX_NAME_LENGTH)
- throw new DBusException("Invalid object path ("+objectpath+")");
+ throw new DBusException(_("Invalid object path: ")+objectpath);
- if (!DBusInterface.class.isAssignableFrom(type)) throw new ClassCastException("Not A DBus Interface");
+ if (!DBusInterface.class.isAssignableFrom(type)) throw new ClassCastException(_("Not A DBus Interface"));
// don't let people import things which don't have a
// valid D-Bus interface name
if (type.getName().equals(type.getSimpleName()))
- throw new DBusException("DBusInterfaces cannot be declared outside a package");
+ throw new DBusException(_("DBusInterfaces cannot be declared outside a package"));
RemoteObject ro = new RemoteObject(null, objectpath, type, false);
DBusInterface i = (DBusInterface) Proxy.newProxyInstance(type.getClassLoader(),
diff --git a/org/freedesktop/dbus/Error.java b/org/freedesktop/dbus/Error.java
index 7280336..947cd67 100644
--- a/org/freedesktop/dbus/Error.java
+++ b/org/freedesktop/dbus/Error.java
@@ -10,6 +10,8 @@
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+
import java.lang.reflect.Constructor;
import java.util.Vector;
import org.freedesktop.dbus.exceptions.DBusException;
@@ -33,7 +35,7 @@ public class Error extends Message
super(Message.Endian.BIG, Message.MessageType.ERROR, (byte) 0);
if (null == errorName)
- throw new MessageFormatException("Must specify error name to Errors.");
+ throw new MessageFormatException(_("Must specify error name to Errors."));
headers.put(Message.HeaderField.REPLY_SERIAL,replyserial);
headers.put(Message.HeaderField.ERROR_NAME,errorName);
diff --git a/org/freedesktop/dbus/ExportedObject.java b/org/freedesktop/dbus/ExportedObject.java
index 51883c3..3677aa9 100644
--- a/org/freedesktop/dbus/ExportedObject.java
+++ b/org/freedesktop/dbus/ExportedObject.java
@@ -10,6 +10,8 @@
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+
import java.lang.ref.WeakReference;
import java.lang.annotation.Annotation;
@@ -62,9 +64,9 @@ class ExportedObject
// don't let people export things which don't have a
// valid D-Bus interface name
if (c.getName().equals(c.getSimpleName()))
- throw new DBusException("DBusInterfaces cannot be declared outside a package");
+ throw new DBusException(_("DBusInterfaces cannot be declared outside a package"));
if (c.getName().length() > DBusConnection.MAX_NAME_LENGTH)
- throw new DBusException("Introspected interface name exceeds 255 characters. Cannot export objects of type "+c.getName()+".");
+ throw new DBusException(_("Introspected interface name exceeds 255 characters. Cannot export objects of type ")+c.getName());
else
introspectiondata += " <interface name=\""+AbstractConnection.dollar_pattern.matcher(c.getName()).replaceAll(".")+"\">\n";
}
@@ -78,7 +80,7 @@ class ExportedObject
else
name = meth.getName();
if (name.length() > DBusConnection.MAX_NAME_LENGTH)
- throw new DBusException("Introspected method name exceeds 255 characters. Cannot export objects with method "+name+".");
+ throw new DBusException(_("Introspected method name exceeds 255 characters. Cannot export objects with method ")+name);
introspectiondata += " <method name=\""+name+"\" >\n";
introspectiondata += getAnnotations(meth);
for (Class ex: meth.getExceptionTypes())
@@ -100,7 +102,7 @@ class ExportedObject
for (String s: Marshalling.getDBusType(t))
introspectiondata += " <arg type=\""+s+"\" direction=\"out\"/>\n";
} else if (Object[].class.equals(meth.getGenericReturnType())) {
- throw new DBusException("Return type of Object[] cannot be introspected properly");
+ throw new DBusException(_("Return type of Object[] cannot be introspected properly"));
} else
for (String s: Marshalling.getDBusType(meth.getGenericReturnType()))
introspectiondata += " <arg type=\""+s+"\" direction=\"out\"/>\n";
@@ -117,7 +119,7 @@ class ExportedObject
} else
name = sig.getSimpleName();
if (name.length() > DBusConnection.MAX_NAME_LENGTH)
- throw new DBusException("Introspected signal name exceeds 255 characters. Cannot export objects with signals of type "+name+".");
+ throw new DBusException(_("Introspected signal name exceeds 255 characters. Cannot export objects with signals of type ")+name);
introspectiondata += " <signal name=\""+name+"\">\n";
Constructor con = sig.getConstructors()[0];
Type[] ts = con.getGenericParameterTypes();
diff --git a/org/freedesktop/dbus/Gettext.java b/org/freedesktop/dbus/Gettext.java
new file mode 100644
index 0000000..dc38189
--- /dev/null
+++ b/org/freedesktop/dbus/Gettext.java
@@ -0,0 +1,30 @@
+/*
+ * Pescetti Pseudo-Duplimate Generator
+ *
+ * Copyright (C) 2007 Matthew Johnson
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License Version 2 as published by
+ * the Free Software Foundation. This program is distributed in the hope that
+ * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details. You should have received a
+ * copy of the GNU General Public License along with this program; if not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * To Contact me, please email src@matthew.ath.cx
+ *
+ */
+package org.freedesktop.dbus;
+
+import java.util.ResourceBundle;
+
+public class Gettext
+{
+ private static ResourceBundle myResources =
+ ResourceBundle.getBundle("dbusjava_localized");
+ public static String _(String s) {
+ return myResources.getString(s);
+ }
+}
diff --git a/org/freedesktop/dbus/Marshalling.java b/org/freedesktop/dbus/Marshalling.java
index 9ba0b44..03a54de 100644
--- a/org/freedesktop/dbus/Marshalling.java
+++ b/org/freedesktop/dbus/Marshalling.java
@@ -10,6 +10,8 @@
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
@@ -18,6 +20,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
+import java.text.MessageFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -94,13 +97,13 @@ public class Marshalling
else out[level].delete(0, out.length);
if (basic && !(c instanceof Class))
- throw new DBusException(c+" is not a basic type");
+ throw new DBusException(c+_(" is not a basic type"));
if (c instanceof TypeVariable) out[level].append((char) Message.ArgumentType.VARIANT);
else if (c instanceof GenericArrayType) {
out[level].append((char) Message.ArgumentType.ARRAY);
String[] s = recursiveGetDBusType(((GenericArrayType) c).getGenericComponentType(), false, level+1);
- if (s.length != 1) throw new DBusException("Multi-valued array types not permitted");
+ if (s.length != 1) throw new DBusException(_("Multi-valued array types not permitted"));
out[level].append(s[0]);
}
else if (c instanceof ParameterizedType) {
@@ -110,14 +113,14 @@ public class Marshalling
Type[] t = p.getActualTypeArguments();
try {
String[] s = recursiveGetDBusType(t[0], true, level+1);
- if (s.length != 1) throw new DBusException("Multi-valued array types not permitted");
+ if (s.length != 1) throw new DBusException(_("Multi-valued array types not permitted"));
out[level].append(s[0]);
s = recursiveGetDBusType(t[1], false, level+1);
- if (s.length != 1) throw new DBusException("Multi-valued array types not permitted");
+ if (s.length != 1) throw new DBusException(_("Multi-valued array types not permitted"));
out[level].append(s[0]);
} catch (ArrayIndexOutOfBoundsException AIOOBe) {
if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, AIOOBe);
- throw new DBusException("Map must have 2 parameters");
+ throw new DBusException(_("Map must have 2 parameters"));
}
out[level].append('}');
}
@@ -127,7 +130,7 @@ public class Marshalling
out[level].append((char) Message.ArgumentType.SIGNATURE);
else {
String[] s = recursiveGetDBusType(t, false, level+1);
- if (s.length != 1) throw new DBusException("Multi-valued array types not permitted");
+ if (s.length != 1) throw new DBusException(_("Multi-valued array types not permitted"));
out[level].append((char) Message.ArgumentType.ARRAY);
out[level].append(s[0]);
}
@@ -148,7 +151,7 @@ public class Marshalling
return vs.toArray(new String[0]);
}
else
- throw new DBusException("Exporting non-exportable parameterized type "+c);
+ throw new DBusException(_("Exporting non-exportable parameterized type ")+c);
}
else if (c.equals(Byte.class)) out[level].append((char) Message.ArgumentType.BYTE);
@@ -184,7 +187,7 @@ public class Marshalling
else {
out[level].append((char) Message.ArgumentType.ARRAY);
String[] s = recursiveGetDBusType(((Class) c).getComponentType(), false, level+1);
- if (s.length != 1) throw new DBusException("Multi-valued array types not permitted");
+ if (s.length != 1) throw new DBusException(_("Multi-valued array types not permitted"));
out[level].append(s[0]);
}
} else if (c instanceof Class &&
@@ -223,17 +226,17 @@ public class Marshalling
if (m.getName().equals("deserialize"))
newtypes = m.getGenericParameterTypes();
- if (null == newtypes) throw new DBusException("Serializable classes must implement a deserialize method");
+ if (null == newtypes) throw new DBusException(_("Serializable classes must implement a deserialize method"));
String[] sigs = new String[newtypes.length];
for (int j = 0; j < sigs.length; j++) {
String[] ss = recursiveGetDBusType(newtypes[j], false, level+1);
- if (1 != ss.length) throw new DBusException("Serializable classes must serialize to native DBus types");
+ if (1 != ss.length) throw new DBusException(_("Serializable classes must serialize to native DBus types"));
sigs[j] = ss[0];
}
return sigs;
} else {
- throw new DBusException("Exporting non-exportable type "+c);
+ throw new DBusException(_("Exporting non-exportable type ")+c);
}
if (Debug.debug) Debug.print(Debug.VERBOSE, "Converted Java type: "+c+" to D-Bus Type: "+out[level]);
@@ -330,12 +333,12 @@ public class Marshalling
i+=c+1;
break;
default:
- throw new DBusException("Failed to parse DBus type signature: "+dbus+" ("+dbus.charAt(i)+")");
+ throw new DBusException(MessageFormat.format(_("Failed to parse DBus type signature: {0} ({1})."), new Object[] { dbus, dbus.charAt(i) }));
}
return i;
} catch (IndexOutOfBoundsException IOOBe) {
if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, IOOBe);
- throw new DBusException("Failed to parse DBus type signature: "+dbus);
+ throw new DBusException(_("Failed to parse DBus type signature: ")+dbus);
}
}
/**
@@ -563,7 +566,7 @@ public class Marshalling
Debug.print(Debug.ERR, String.format("Error, Parameters difference (%1d, '%2s')", j, parameters[j].toString()));
}
}
- throw new DBusException("Error deserializing message: number of parameters didn't match receiving signature");
+ throw new DBusException(_("Error deserializing message: number of parameters didn't match receiving signature"));
}
if (null == parameters[i]) continue;
@@ -585,7 +588,8 @@ public class Marshalling
parameters = compress;
} catch (ArrayIndexOutOfBoundsException AIOOBe) {
if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, AIOOBe);
- throw new DBusException("Not enough elements to create custom object from serialized data ("+(parameters.length-i)+" < "+(newtypes.length)+")");
+ throw new DBusException(MessageFormat.format(_("Not enough elements to create custom object from serialized data ({0} < {1})."),
+ new Object[] { parameters.length-i, newtypes.length }));
}
}
} else
diff --git a/org/freedesktop/dbus/Message.java b/org/freedesktop/dbus/Message.java
index c4ab12d..135e0cb 100644
--- a/org/freedesktop/dbus/Message.java
+++ b/org/freedesktop/dbus/Message.java
@@ -10,9 +10,12 @@
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+
import java.lang.reflect.Array;
import java.lang.reflect.Type;
import java.io.UnsupportedEncodingException;
+import java.text.MessageFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -238,7 +241,7 @@ public class Message
if (null == buf) return;
if (preallocated > 0) {
if (paofs+buf.length > pabuf.length)
- throw new RuntimeException("Array index out of bounds, paofs="+paofs+", pabuf.length="+pabuf.length+", buf.length="+buf.length);
+ throw new ArrayIndexOutOfBoundsException(MessageFormat.format(_("Array index out of bounds, paofs={0}, pabuf.length={1}, buf.length={2}."), new Object[] { paofs, pabuf.length, buf.length }));
System.arraycopy(buf, 0, pabuf, paofs, buf.length);
paofs += buf.length;
preallocated -= buf.length;
@@ -519,7 +522,7 @@ public class Message
payloadbytes = payload.getBytes("UTF-8");
} catch (UnsupportedEncodingException UEe) {
if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(UEe);
- throw new DBusException("System does not support UTF-8 encoding");
+ throw new DBusException(_("System does not support UTF-8 encoding"));
}
if (Debug.debug) Debug.print(Debug.VERBOSE, "Appending String of length "+payloadbytes.length);
appendint(payloadbytes.length, 4);
@@ -598,7 +601,7 @@ public class Message
primbuf, k, algn);
break;
default:
- throw new MarshallingException("Primative array being sent as non-primative array.");
+ throw new MarshallingException(_("Primative array being sent as non-primative array."));
}
appendBytes(primbuf);
i++;
@@ -680,7 +683,7 @@ public class Message
return i;
} catch (ClassCastException CCe) {
if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, CCe);
- throw new MarshallingException("Trying to marshall to unconvertable type (from "+data.getClass().getName()+" to "+sigb[sigofs]+")");
+ throw new MarshallingException(MessageFormat.format(_("Trying to marshall to unconvertable type (from {0} to {1})."), new Object[] { data.getClass().getName(), sigb[sigofs] }));
}
}
/**
@@ -844,7 +847,7 @@ public class Message
ofs[1] = align(ofs[1], sigb[ofs[0]]);
int length = (int) (size / algn);
if (length > DBusConnection.MAX_ARRAY_LENGTH)
- throw new MarshallingException("Arrays must not exceed "+DBusConnection.MAX_ARRAY_LENGTH);
+ throw new MarshallingException(_("Arrays must not exceed ")+DBusConnection.MAX_ARRAY_LENGTH);
// optimise primatives
switch (sigb[ofs[0]]) {
case ArgumentType.BYTE:
@@ -959,7 +962,7 @@ public class Message
rv = new String(buf, ofs[1], length, "UTF-8");
} catch (UnsupportedEncodingException UEe) {
if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(UEe);
- throw new DBusException("System does not support UTF-8 encoding");
+ throw new DBusException(_("System does not support UTF-8 encoding"));
}
ofs[1] += length + 1;
break;
diff --git a/org/freedesktop/dbus/MessageReader.java b/org/freedesktop/dbus/MessageReader.java
index 5c30795..9a28a2d 100644
--- a/org/freedesktop/dbus/MessageReader.java
+++ b/org/freedesktop/dbus/MessageReader.java
@@ -10,10 +10,13 @@
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+
import java.io.InputStream;
import java.io.IOException;
import java.io.EOFException;
import java.net.SocketTimeoutException;
+import java.text.MessageFormat;
import cx.ath.matthew.debug.Debug;
import cx.ath.matthew.utils.Hexdump;
@@ -42,7 +45,7 @@ public class MessageReader
if (len[0] < 12) {
try { rv = in.read(buf, len[0], 12-len[0]); }
catch (SocketTimeoutException STe) { return null; }
- if (-1 == rv) throw new EOFException("Underlying transport returned EOF");
+ if (-1 == rv) throw new EOFException(_("Underlying transport returned EOF"));
len[0] += rv;
}
if (len[0] == 0) return null;
@@ -57,7 +60,7 @@ public class MessageReader
byte protover = buf[3];
if (protover > Message.PROTOCOL) {
buf = null;
- throw new MessageProtocolVersionException("Protocol version "+protover+" is unsupported");
+ throw new MessageProtocolVersionException(MessageFormat.format(_("Protocol version {0} is unsupported"), new Object[] { protover }));
}
/* Read the length of the variable header */
@@ -65,7 +68,7 @@ public class MessageReader
if (len[1] < 4) {
try { rv = in.read(tbuf, len[1], 4-len[1]); }
catch (SocketTimeoutException STe) { return null; }
- if (-1 == rv) throw new EOFException("Underlying transport returned EOF");
+ if (-1 == rv) throw new EOFException(_("Underlying transport returned EOF"));
len[1] += rv;
}
if (len[1] < 4) {
@@ -91,7 +94,7 @@ public class MessageReader
if (len[2] < headerlen) {
try { rv = in.read(header, 8+len[2], headerlen-len[2]); }
catch (SocketTimeoutException STe) { return null; }
- if (-1 == rv) throw new EOFException("Underlying transport returned EOF");
+ if (-1 == rv) throw new EOFException(_("Underlying transport returned EOF"));
len[2] += rv;
}
if (len[2] < headerlen) {
@@ -106,7 +109,7 @@ public class MessageReader
if (len[3] < body.length) {
try { rv = in.read(body, len[3], body.length-len[3]); }
catch (SocketTimeoutException STe) { return null; }
- if (-1 == rv) throw new EOFException("Underlying transport returned EOF");
+ if (-1 == rv) throw new EOFException(_("Underlying transport returned EOF"));
len[3] += rv;
}
if (len[3] < body.length) {
@@ -129,7 +132,7 @@ public class MessageReader
m = new Error();
break;
default:
- throw new MessageTypeException("Message type "+type+" unsupported");
+ throw new MessageTypeException(MessageFormat.format(_("Message type {0} unsupported"), new Object[] {type}));
}
if (Debug.debug) {
Debug.print(Debug.VERBOSE, Hexdump.format(buf));
diff --git a/org/freedesktop/dbus/MethodCall.java b/org/freedesktop/dbus/MethodCall.java
index 40a5712..9ed96ec 100644
--- a/org/freedesktop/dbus/MethodCall.java
+++ b/org/freedesktop/dbus/MethodCall.java
@@ -10,6 +10,8 @@
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+
import java.util.Vector;
import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.exceptions.MessageFormatException;
@@ -28,7 +30,7 @@ public class MethodCall extends Message
super(Message.Endian.BIG, Message.MessageType.METHOD_CALL, flags);
if (null == member || null == path)
- throw new MessageFormatException("Must specify destination, path and function name to MethodCalls.");
+ throw new MessageFormatException(_("Must specify destination, path and function name to MethodCalls."));
headers.put(Message.HeaderField.PATH,path);
headers.put(Message.HeaderField.MEMBER,member);
diff --git a/org/freedesktop/dbus/RemoteInvocationHandler.java b/org/freedesktop/dbus/RemoteInvocationHandler.java
index 106438d..597c03f 100644
--- a/org/freedesktop/dbus/RemoteInvocationHandler.java
+++ b/org/freedesktop/dbus/RemoteInvocationHandler.java
@@ -10,6 +10,8 @@
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.GenericArrayType;
@@ -19,6 +21,7 @@ import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Proxy;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
+import java.text.MessageFormat;
import java.util.List;
import org.freedesktop.DBus;
@@ -39,14 +42,14 @@ class RemoteInvocationHandler implements InvocationHandler
if (null == rp) {
if(null == c || Void.TYPE.equals(c)) return null;
- else throw new DBusExecutionException("Wrong return type (got void, expected a value)");
+ else throw new DBusExecutionException(_("Wrong return type (got void, expected a value)"));
}
switch (rp.length) {
case 0:
if (null == c || Void.TYPE.equals(c))
return null;
- else throw new DBusExecutionException("Wrong return type (got void, expected a value)");
+ else throw new DBusExecutionException(_("Wrong return type (got void, expected a value)"));
case 1:
try {
rp = Marshalling.deSerializeParameters(rp,
@@ -54,7 +57,7 @@ class RemoteInvocationHandler implements InvocationHandler
}
catch (Exception e) {
if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
- throw new DBusExecutionException("Wrong return type (failed to de-serialize correct types: "+e.getMessage()+")");
+ throw new DBusExecutionException(MessageFormat.format(_("Wrong return type (failed to de-serialize correct types: {0} )"), new Object[] { e.getMessage() }));
}
return rp[0];
@@ -62,12 +65,12 @@ class RemoteInvocationHandler implements InvocationHandler
// check we are meant to return multiple values
if (!Tuple.class.isAssignableFrom(c))
- throw new DBusExecutionException("Wrong return type (not expecting Tuple)");
+ throw new DBusExecutionException(_("Wrong return type (not expecting Tuple)"));
try {
rp = Marshalling.deSerializeParameters(rp, ((ParameterizedType) m.getGenericReturnType()).getActualTypeArguments(), conn);
} catch (Exception e) {
if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
- throw new DBusExecutionException("Wrong return type (failed to de-serialize correct types: "+e.getMessage()+")");
+ throw new DBusExecutionException(MessageFormat.format(_("Wrong return type (failed to de-serialize correct types: {0})"), new Object[] {e.getMessage()}));
}
Constructor cons = c.getConstructors()[0];
try {
@@ -86,7 +89,7 @@ class RemoteInvocationHandler implements InvocationHandler
sig = Marshalling.getDBusType(ts);
args = Marshalling.convertParameters(args, ts, conn);
} catch (DBusException DBe) {
- throw new DBusExecutionException("Failed to construct D-Bus type: "+DBe.getMessage());
+ throw new DBusExecutionException(_("Failed to construct D-Bus type: ")+DBe.getMessage());
}
MethodCall call;
byte flags = 0;
@@ -109,9 +112,9 @@ class RemoteInvocationHandler implements InvocationHandler
}
} catch (DBusException DBe) {
if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBe);
- throw new DBusExecutionException("Failed to construct outgoing method call: "+DBe.getMessage());
+ throw new DBusExecutionException(_("Failed to construct outgoing method call: ")+DBe.getMessage());
}
- if (null == conn.outgoing) throw new NotConnected("Not Connected");
+ if (null == conn.outgoing) throw new NotConnected(_("Not Connected"));
switch (syncmethod) {
case CALL_TYPE_ASYNC:
@@ -134,7 +137,7 @@ class RemoteInvocationHandler implements InvocationHandler
if (m.isAnnotationPresent(DBus.Method.NoReply.class)) return null;
Message reply = call.getReply();
- if (null == reply) throw new DBus.Error.NoReply("No reply within specified time");
+ if (null == reply) throw new DBus.Error.NoReply(_("No reply within specified time"));
if (reply instanceof Error)
((Error) reply).throwException();
diff --git a/org/freedesktop/dbus/Transport.java b/org/freedesktop/dbus/Transport.java
index 37b631d..a80e8ef 100644
--- a/org/freedesktop/dbus/Transport.java
+++ b/org/freedesktop/dbus/Transport.java
@@ -10,6 +10,8 @@
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+
import java.io.BufferedReader;
import java.io.EOFException;
import java.io.File;
@@ -24,6 +26,7 @@ import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
+import java.text.ParseException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.Collator;
@@ -88,7 +91,7 @@ public class Transport
command = COMMAND_ERROR;
data = ss[1];
} else {
- throw new IOException("Invalid Command "+ss[0]);
+ throw new IOException(_("Invalid Command ")+ss[0]);
}
if (Debug.debug) Debug.print(Debug.VERBOSE, "Created command: "+this);
}
@@ -706,19 +709,19 @@ public class Transport
{
connect(address);
}
- public Transport(String address) throws IOException
+ public Transport(String address) throws IOException, ParseException
{
connect(new BusAddress(address));
}
- public Transport(String address, int timeout) throws IOException
+ public Transport(String address, int timeout) throws IOException, ParseException
{
connect(new BusAddress(address), timeout);
}
- public void connect(String address) throws IOException
+ public void connect(String address) throws IOException, ParseException
{
connect(new BusAddress(address), 0);
}
- public void connect(String address, int timeout) throws IOException
+ public void connect(String address, int timeout) throws IOException, ParseException
{
connect(new BusAddress(address), timeout);
}
@@ -772,12 +775,12 @@ public class Transport
in = s.getInputStream();
out = s.getOutputStream();
} else {
- throw new IOException("unknown address type "+address.getType());
+ throw new IOException(_("unknown address type ")+address.getType());
}
if (!(new SASL()).auth(mode, types, address.getParameter("guid"), out, in)) {
out.close();
- throw new IOException("Failed to auth");
+ throw new IOException(_("Failed to auth"));
}
if (null != us) {
if (Debug.debug) Debug.print(Debug.VERBOSE, "Setting timeout to "+timeout+" on Socket");
diff --git a/org/freedesktop/dbus/UInt16.java b/org/freedesktop/dbus/UInt16.java
index 44ddf45..fb21c9e 100644
--- a/org/freedesktop/dbus/UInt16.java
+++ b/org/freedesktop/dbus/UInt16.java
@@ -10,6 +10,10 @@
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+
+import java.text.MessageFormat;
+
/**
* Class to represent 16-bit unsigned integers.
*/
@@ -28,7 +32,7 @@ public class UInt16 extends Number implements Comparable<UInt16>
public UInt16(int value)
{
if (value < MIN_VALUE || value > MAX_VALUE)
- throw new NumberFormatException(value +" is not between "+ MIN_VALUE +" and "+ MAX_VALUE);
+ throw new NumberFormatException(MessageFormat.format(_("{0} is not between {1} and {2}."), new Object[] { value, MIN_VALUE, MAX_VALUE}));
this.value = value;
}
/** Create a UInt16 from a String.
diff --git a/org/freedesktop/dbus/UInt32.java b/org/freedesktop/dbus/UInt32.java
index 96bbb7a..5bacc0c 100644
--- a/org/freedesktop/dbus/UInt32.java
+++ b/org/freedesktop/dbus/UInt32.java
@@ -10,6 +10,10 @@
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+
+import java.text.MessageFormat;
+
/**
* Class to represent unsigned 32-bit numbers.
*/
@@ -28,7 +32,7 @@ public class UInt32 extends Number implements Comparable<UInt32>
public UInt32(long value)
{
if (value < MIN_VALUE || value > MAX_VALUE)
- throw new NumberFormatException(value +" is not between "+ MIN_VALUE +" and "+ MAX_VALUE);
+ throw new NumberFormatException(MessageFormat.format(_("{0} is not between {1} and {2}."), new Object[] { value, MIN_VALUE, MAX_VALUE}));
this.value = value;
}
/** Create a UInt32 from a String.
diff --git a/org/freedesktop/dbus/UInt64.java b/org/freedesktop/dbus/UInt64.java
index abb6de1..855e1aa 100644
--- a/org/freedesktop/dbus/UInt64.java
+++ b/org/freedesktop/dbus/UInt64.java
@@ -10,8 +10,12 @@
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+
import java.math.BigInteger;
+import java.text.MessageFormat;
+
/**
* Class to represent unsigned 64-bit numbers.
* Warning: Any functions which take or return a <tt>long</tt>
@@ -38,7 +42,7 @@ public class UInt64 extends Number implements Comparable<UInt64>
public UInt64(long value)
{
if (value < MIN_VALUE || value > MAX_LONG_VALUE)
- throw new NumberFormatException(value +" is not between "+ MIN_VALUE +" and "+ MAX_LONG_VALUE);
+ throw new NumberFormatException(MessageFormat.format(_("{0} is not between {1} and {2}."), new Object[] { value, MIN_VALUE, MAX_LONG_VALUE}));
this.value = new BigInteger(""+value);
this.top = this.value.shiftRight(32).and(new BigInteger("4294967295")).longValue();
this.bottom = this.value.and(new BigInteger("4294967295")).longValue();
@@ -54,9 +58,9 @@ public class UInt64 extends Number implements Comparable<UInt64>
a = a.shiftLeft(32);
a = a.add(new BigInteger(""+bottom));
if (0 > a.compareTo(BigInteger.ZERO))
- throw new NumberFormatException(a +" is not between "+ MIN_VALUE +" and "+ MAX_BIG_VALUE);
+ throw new NumberFormatException(MessageFormat.format(_("{0} is not between {1} and {2}."), new Object[] { a, MIN_VALUE, MAX_BIG_VALUE}));
if (0 < a.compareTo(MAX_BIG_VALUE))
- throw new NumberFormatException(a +" is not between "+ MIN_VALUE +" and "+ MAX_BIG_VALUE);
+ throw new NumberFormatException(MessageFormat.format(_("{0} is not between {1} and {2}."), new Object[] { a, MIN_VALUE, MAX_BIG_VALUE}));
this.value = a;
this.top = top;
this.bottom = bottom;
@@ -68,11 +72,11 @@ public class UInt64 extends Number implements Comparable<UInt64>
public UInt64(BigInteger value)
{
if (null == value)
- throw new NumberFormatException(value +" is not between "+ MIN_VALUE +" and "+ MAX_BIG_VALUE);
+ throw new NumberFormatException(MessageFormat.format(_("{0} is not between {1} and {2}."), new Object[] { value, MIN_VALUE, MAX_BIG_VALUE}));
if (0 > value.compareTo(BigInteger.ZERO))
- throw new NumberFormatException(value +" is not between "+ MIN_VALUE +" and "+ MAX_BIG_VALUE);
+ throw new NumberFormatException(MessageFormat.format(_("{0} is not between {1} and {2}."), new Object[] { value, MIN_VALUE, MAX_BIG_VALUE}));
if (0 < value.compareTo(MAX_BIG_VALUE))
- throw new NumberFormatException(value +" is not between "+ MIN_VALUE +" and "+ MAX_BIG_VALUE);
+ throw new NumberFormatException(MessageFormat.format(_("{0} is not between {1} and {2}."), new Object[] { value, MIN_VALUE, MAX_BIG_VALUE}));
this.value = value;
this.top = this.value.shiftRight(32).and(new BigInteger("4294967295")).longValue();
this.bottom = this.value.and(new BigInteger("4294967295")).longValue();
@@ -84,12 +88,12 @@ public class UInt64 extends Number implements Comparable<UInt64>
public UInt64(String value)
{
if (null == value)
- throw new NumberFormatException(value +" is not between "+ MIN_VALUE +" and "+ MAX_BIG_VALUE);
+ throw new NumberFormatException(MessageFormat.format(_("{0} is not between {1} and {2}."), new Object[] { value, MIN_VALUE, MAX_BIG_VALUE}));
BigInteger a = new BigInteger(value);
if (0 > a.compareTo(BigInteger.ZERO))
- throw new NumberFormatException(a +" is not between "+ MIN_VALUE +" and "+ MAX_BIG_VALUE);
+ throw new NumberFormatException(MessageFormat.format(_("{0} is not between {1} and {2}."), new Object[] { value, MIN_VALUE, MAX_BIG_VALUE}));
if (0 < a.compareTo(MAX_BIG_VALUE))
- throw new NumberFormatException(a +" is not between "+ MIN_VALUE +" and "+ MAX_BIG_VALUE);
+ throw new NumberFormatException(MessageFormat.format(_("{0} is not between {1} and {2}."), new Object[] { value, MIN_VALUE, MAX_BIG_VALUE}));
this.value = a;
this.top = this.value.shiftRight(32).and(new BigInteger("4294967295")).longValue();
this.bottom = this.value.and(new BigInteger("4294967295")).longValue();
diff --git a/org/freedesktop/dbus/Variant.java b/org/freedesktop/dbus/Variant.java
index 73b52d0..c5c9673 100644
--- a/org/freedesktop/dbus/Variant.java
+++ b/org/freedesktop/dbus/Variant.java
@@ -10,7 +10,10 @@
*/
package org.freedesktop.dbus;
+import static org.freedesktop.dbus.Gettext._;
+
import java.lang.reflect.Type;
+import java.text.MessageFormat;
import java.util.Vector;
import org.freedesktop.dbus.exceptions.DBusException;
@@ -34,16 +37,16 @@ public class Variant<T>
*/
public Variant(T o) throws IllegalArgumentException
{
- if (null == o) throw new IllegalArgumentException("Can't wrap Null in a Variant");
+ if (null == o) throw new IllegalArgumentException(_("Can't wrap Null in a Variant"));
type = o.getClass();
try {
String[] ss = Marshalling.getDBusType(o.getClass(), true);
if (ss.length != 1)
- throw new IllegalArgumentException("Can't wrap a multi-valued type in a Variant ("+type+")");
+ throw new IllegalArgumentException(_("Can't wrap a multi-valued type in a Variant: ")+type);
this.sig = ss[0];
} catch (DBusException DBe) {
if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBe);
- throw new IllegalArgumentException("Can't wrap "+o.getClass()+" in an unqualified Variant ("+DBe.getMessage()+")");
+ throw new IllegalArgumentException(MessageFormat.format(_("Can't wrap {0} in an unqualified Variant ({1})."), new Object[] { o.getClass(), DBe.getMessage() }));
}
this.o = o;
}
@@ -55,16 +58,16 @@ public class Variant<T>
*/
public Variant(T o, Type type) throws IllegalArgumentException
{
- if (null == o) throw new IllegalArgumentException("Can't wrap Null in a Variant");
+ if (null == o) throw new IllegalArgumentException(_("Can't wrap Null in a Variant"));
this.type = type;
try {
String[] ss = Marshalling.getDBusType(type);
if (ss.length != 1)
- throw new IllegalArgumentException("Can't wrap a multi-valued type in a Variant ("+type+")");
+ throw new IllegalArgumentException(_("Can't wrap a multi-valued type in a Variant: ")+type);
this.sig = ss[0];
} catch (DBusException DBe) {
if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBe);
- throw new IllegalArgumentException("Can't wrap a "+type+" in a Variant ("+DBe.getMessage()+")");
+ throw new IllegalArgumentException(MessageFormat.format(_("Can't wrap {0} in an unqualified Variant ({1})."), new Object[] { type, DBe.getMessage() }));
}
this.o = o;
}
@@ -76,17 +79,17 @@ public class Variant<T>
*/
public Variant(T o, String sig) throws IllegalArgumentException
{
- if (null == o) throw new IllegalArgumentException("Can't wrap Null in a Variant");
+ if (null == o) throw new IllegalArgumentException(_("Can't wrap Null in a Variant"));
this.sig = sig;
try {
Vector<Type> ts = new Vector<Type>();
Marshalling.getJavaType(sig, ts,1);
if (ts.size() != 1)
- throw new IllegalArgumentException("Can't wrap multiple or no types in a Variant ("+sig+")");
+ throw new IllegalArgumentException(_("Can't wrap multiple or no types in a Variant: ")+sig);
this.type = ts.get(0);
} catch (DBusException DBe) {
if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBe);
- throw new IllegalArgumentException("Can't wrap a "+sig+" in a Variant ("+DBe.getMessage()+")");
+ throw new IllegalArgumentException(MessageFormat.format(_("Can't wrap {0} in an unqualified Variant ({1})."), new Object[] { sig, DBe.getMessage() }));
}
this.o = o;
}
diff --git a/org/freedesktop/dbus/bin/CreateInterface.java b/org/freedesktop/dbus/bin/CreateInterface.java
index 8621842..fe769eb 100644
--- a/org/freedesktop/dbus/bin/CreateInterface.java
+++ b/org/freedesktop/dbus/bin/CreateInterface.java
@@ -10,6 +10,8 @@
*/
package org.freedesktop.dbus.bin;
+import static org.freedesktop.dbus.Gettext._;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -19,6 +21,7 @@ import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.Reader;
import java.io.StringReader;
+import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -151,7 +154,7 @@ public class CreateInterface
Vector<Element> out = new Vector<Element>();
if (null == meth.getAttribute("name") ||
"".equals(meth.getAttribute("name"))) {
- System.err.println("ERROR: Interface name was blank, failed");
+ System.err.println(_("ERROR: Interface name was blank, failed"));
System.exit(1);
}
String annotations = "";
@@ -266,7 +269,7 @@ public class CreateInterface
{
if (null == iface.getAttribute("name") ||
"".equals(iface.getAttribute("name"))) {
- System.err.println("ERROR: Interface name was blank, failed");
+ System.err.println(_("ERROR: Interface name was blank, failed"));
System.exit(1);
}
@@ -435,7 +438,7 @@ public class CreateInterface
else if ("node".equals(iface.getNodeName()))
parseRoot((Element) iface);
else {
- System.err.println("ERROR: Unknown node: "+iface.getNodeName()+".");
+ System.err.println(_("ERROR: Unknown node: ")+iface.getNodeName());
System.exit(1);
}
}
@@ -568,7 +571,7 @@ public class CreateInterface
if (name.equals(n.getNodeName())) return;
expected += name + " or ";
}
- System.err.println("ERROR: Expected "+expected.replaceAll("....$", "")+", got "+n.getNodeName()+", failed.");
+ System.err.println(MessageFormat.format(_("ERROR: Expected {0}, got {1}, failed."), new Object[] { expected.replaceAll("....$", ""), n.getNodeName() }));
System.exit(1);
}
@@ -621,7 +624,7 @@ public class CreateInterface
version();
System.exit(0);
} else if (p.startsWith("-")) {
- System.err.println("ERROR: Unknown option: "+p);
+ System.err.println(_("ERROR: Unknown option: ")+p);
printSyntax();
System.exit(1);
}
@@ -656,22 +659,22 @@ public class CreateInterface
Introspectable in = conn.getRemoteObject(config.busname, config.object, Introspectable.class);
String id = in.Introspect();
if (null == id) {
- System.err.println("ERROR: Failed to get introspection data");
+ System.err.println(_("ERROR: Failed to get introspection data"));
System.exit(1);
}
introspectdata = new StringReader(id);
conn.disconnect();
} catch (DBusException DBe) {
- System.err.println("ERROR: Failure in DBus Communications: "+DBe.getMessage());
+ System.err.println(_("ERROR: Failure in DBus Communications: ")+DBe.getMessage());
System.exit(1);
} catch (DBusExecutionException DEe) {
- System.err.println("ERROR: Failure in DBus Communications: "+DEe.getMessage());
+ System.err.println(_("ERROR: Failure in DBus Communications: ")+DEe.getMessage());
System.exit(1);
} else if (null != config.datafile) try {
introspectdata = new InputStreamReader(new FileInputStream(config.datafile));
} catch (FileNotFoundException FNFe) {
- System.err.println("ERROR: Could not find introspection file: "+FNFe.getMessage());
+ System.err.println(_("ERROR: Could not find introspection file: ")+FNFe.getMessage());
System.exit(1);
}
try {
diff --git a/org/freedesktop/dbus/bin/DBusDaemon.java b/org/freedesktop/dbus/bin/DBusDaemon.java
index 4e871cb..c5e9891 100644
--- a/org/freedesktop/dbus/bin/DBusDaemon.java
+++ b/org/freedesktop/dbus/bin/DBusDaemon.java
@@ -10,6 +10,8 @@
*/
package org.freedesktop.dbus.bin;
+import static org.freedesktop.dbus.Gettext._;
+
import org.freedesktop.DBus;
import org.freedesktop.dbus.AbstractConnection;
import org.freedesktop.dbus.BusAddress;
@@ -37,6 +39,7 @@ import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
+import java.text.MessageFormat;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -132,7 +135,7 @@ public class DBusDaemon extends Thread
if (Debug.debug) Debug.print(Debug.DEBUG, "enter");
synchronized (c) {
if (null != c.unique)
- throw new org.freedesktop.DBus.Error.AccessDenied("Connection has already sent a Hello message");
+ throw new org.freedesktop.DBus.Error.AccessDenied(_("Connection has already sent a Hello message"));
synchronized (unique_lock) {
c.unique = ":1."+(++next_unique);
}
@@ -333,10 +336,10 @@ public class DBusDaemon extends Thread
send(c, new org.freedesktop.dbus.Error("org.freedesktop.DBus", m, DBEe));
} catch (Exception e) {
if (Debug.debug && AbstractConnection.EXCEPTION_DEBUG) Debug.print(Debug.ERR, e);
- send(c,new org.freedesktop.dbus.Error("org.freedesktop.DBus", c.unique, "org.freedesktop.DBus.Error.GeneralError", m.getSerial(), "s", "An error occurred while calling the "+m.getName()+" Method"));
+ send(c,new org.freedesktop.dbus.Error("org.freedesktop.DBus", c.unique, "org.freedesktop.DBus.Error.GeneralError", m.getSerial(), "s", _("An error occurred while calling ")+m.getName()));
}
} catch (NoSuchMethodException NSMe) {
- send(c,new org.freedesktop.dbus.Error("org.freedesktop.DBus", c.unique, "org.freedesktop.DBus.Error.UnknownMethod", m.getSerial(), "s", "This service does not support the "+m.getName()+" Method"));
+ send(c,new org.freedesktop.dbus.Error("org.freedesktop.DBus", c.unique, "org.freedesktop.DBus.Error.UnknownMethod", m.getSerial(), "s", _("This service does not support ")+m.getName()));
}
if (Debug.debug) Debug.print(Debug.DEBUG, "exit");
@@ -625,13 +628,13 @@ public class DBusDaemon extends Thread
&& (!(m instanceof MethodCall)
|| !"org.freedesktop.DBus".equals(m.getDestination())
|| !"Hello".equals(m.getName()))) {
- send(c,new Error("org.freedesktop.DBus", null, "org.freedesktop.DBus.Error.AccessDenied", m.getSerial(), "s", "You must send a Hello message"));
+ send(c,new Error("org.freedesktop.DBus", null, "org.freedesktop.DBus.Error.AccessDenied", m.getSerial(), "s", _("You must send a Hello message")));
} else {
try {
if (null != c.unique) m.setSource(c.unique);
} catch (DBusException DBe) {
if (Debug.debug && AbstractConnection.EXCEPTION_DEBUG) Debug.print(Debug.ERR, DBe);
- send(c,new Error("org.freedesktop.DBus", null, "org.freedesktop.DBus.Error.GeneralError", m.getSerial(), "s", "Sending message failed"));
+ send(c,new Error("org.freedesktop.DBus", null, "org.freedesktop.DBus.Error.GeneralError", m.getSerial(), "s", _("Sending message failed")));
}
if ("org.freedesktop.DBus".equals(m.getDestination())) {
@@ -648,7 +651,7 @@ public class DBusDaemon extends Thread
Connstruct dest = names.get(m.getDestination());
if (null == dest) {
- send(c, new Error("org.freedesktop.DBus", null, "org.freedesktop.DBus.Error.ServiceUnknown", m.getSerial(), "s", "The name `"+m.getDestination()+"'does not exist"));
+ send(c, new Error("org.freedesktop.DBus", null, "org.freedesktop.DBus.Error.ServiceUnknown", m.getSerial(), "s", MessageFormat.format(_("The name `{0}' does not exist"), new Object[] { m.getDestination() })));
} else
send(dest, m);
}
diff --git a/org/freedesktop/dbus/viewer/DBusViewer.java b/org/freedesktop/dbus/viewer/DBusViewer.java
index af33b88..660dae1 100644
--- a/org/freedesktop/dbus/viewer/DBusViewer.java
+++ b/org/freedesktop/dbus/viewer/DBusViewer.java
@@ -9,6 +9,9 @@
Full licence texts are included in the COPYING file with this program.
*/
package org.freedesktop.dbus.viewer;
+
+import static org.freedesktop.dbus.Gettext._;
+
import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
@@ -119,7 +122,7 @@ public class DBusViewer
{
for (final String key : connectionTypes.keySet())
{
- final JLabel label = new JLabel("Processing DBus for " + key);
+ final JLabel label = new JLabel(_("Processing DBus for ") + key);
tabbedPane.addTab(key, label);
}
Runnable loader = new Runnable()
@@ -176,7 +179,7 @@ public class DBusViewer
JLabel label = (JLabel) tabbedPane
.getComponentAt(index);
label
- .setText("Could not load Dbus information for "
+ .setText(_("Could not load Dbus information for ")
+ key + ":" + e.getMessage());
}
});
@@ -192,7 +195,7 @@ public class DBusViewer
JLabel label = (JLabel) tabbedPane
.getComponentAt(index);
label
- .setText("Could not load Dbus information for "
+ .setText(_("Could not load Dbus information for ")
+ key + ":" + e.getMessage());
}
});
@@ -289,7 +292,7 @@ public class DBusViewer
builder = factory.newDocumentBuilder();
} catch (ParserConfigurationException e1) {
// TODO Auto-generated catch block
- throw new RuntimeException("Error during parser init:"+e1.getMessage(),e1);
+ throw new RuntimeException(_("Error during parser init: ")+e1.getMessage(),e1);
}
reset();
diff --git a/org/freedesktop/dbus/viewer/FileSaver.java b/org/freedesktop/dbus/viewer/FileSaver.java
index 3727c62..78b94c7 100644
--- a/org/freedesktop/dbus/viewer/FileSaver.java
+++ b/org/freedesktop/dbus/viewer/FileSaver.java
@@ -10,6 +10,8 @@
*/
package org.freedesktop.dbus.viewer;
+import static org.freedesktop.dbus.Gettext._;
+
import java.awt.Component;
import java.io.BufferedWriter;
import java.io.File;
@@ -112,8 +114,8 @@ final class FileSaver implements Runnable
int confirm = JOptionPane.showConfirmDialog(
parentComponent, errorMessage
- + ".\nTry saving other files?",
- "Save Failed",
+ + ".\n"+_("Try saving other files?"),
+ _("Save Failed"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.ERROR_MESSAGE);
if (confirm != JOptionPane.OK_OPTION)
@@ -124,7 +126,7 @@ final class FileSaver implements Runnable
else
{
JOptionPane.showMessageDialog(parentComponent,
- errorMessage + ".", "Save Failed",
+ errorMessage + ".", _("Save Failed"),
JOptionPane.ERROR_MESSAGE);
}
}
@@ -133,15 +135,15 @@ final class FileSaver implements Runnable
else
{
- final String errorMessage = "Could not access parent directory for "
+ final String errorMessage = _("Could not access parent directory for ")
+ fileName;
if (iterator.hasNext())
{
int confirm = JOptionPane.showConfirmDialog(
parentComponent, errorMessage
- + ".\nTry saving other files?",
- "Save Failed", JOptionPane.OK_CANCEL_OPTION,
+ + ".\n"+_("Try saving other files?"),
+ _("Save Failed"), JOptionPane.OK_CANCEL_OPTION,
JOptionPane.ERROR_MESSAGE);
if (confirm != JOptionPane.OK_OPTION)
{
@@ -151,7 +153,7 @@ final class FileSaver implements Runnable
else
{
JOptionPane.showMessageDialog(parentComponent, errorMessage
- + ".", "Save Failed", JOptionPane.ERROR_MESSAGE);
+ + ".", _("Save Failed"), JOptionPane.ERROR_MESSAGE);
}
}
}
diff --git a/org/freedesktop/dbus/viewer/SaveFileAction.java b/org/freedesktop/dbus/viewer/SaveFileAction.java
index 89dcbe3..c0ff6b0 100644
--- a/org/freedesktop/dbus/viewer/SaveFileAction.java
+++ b/org/freedesktop/dbus/viewer/SaveFileAction.java
@@ -10,6 +10,8 @@
*/
package org.freedesktop.dbus.viewer;
+import static org.freedesktop.dbus.Gettext._;
+
import java.util.Iterator;
import java.util.NoSuchElementException;
@@ -35,7 +37,7 @@ class SaveFileAction extends TabbedSaveAction implements ChangeListener
{
if (iterated)
{
- throw new NoSuchElementException("Already iterated");
+ throw new NoSuchElementException(_("Already iterated"));
}
iterated = true;
return getTextFile(tabbedPane.getSelectedIndex());
@@ -71,7 +73,7 @@ class SaveFileAction extends TabbedSaveAction implements ChangeListener
{
int selectedIndex = tabbedPane.getSelectedIndex();
boolean enabled = selectedIndex > -1;
- putValue(Action.NAME, "Save " + getFileName(selectedIndex) + "...");
+ putValue(Action.NAME, _("Save ") + getFileName(selectedIndex) + "...");
setEnabled(enabled);
}
diff --git a/org/freedesktop/dbus/viewer/TabbedSaveAction.java b/org/freedesktop/dbus/viewer/TabbedSaveAction.java
index 85e567a..3b2d0fd 100644
--- a/org/freedesktop/dbus/viewer/TabbedSaveAction.java
+++ b/org/freedesktop/dbus/viewer/TabbedSaveAction.java
@@ -10,6 +10,8 @@
*/
package org.freedesktop.dbus.viewer;
+import static org.freedesktop.dbus.Gettext._;
+
import java.awt.event.ActionEvent;
import java.io.File;
@@ -77,7 +79,7 @@ abstract class TabbedSaveAction extends AbstractAction implements Iterable<TextF
chooser = new JFileChooser();
}
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
- chooser.setDialogTitle("Select parent directory for saving");
+ chooser.setDialogTitle(_("Select parent directory for saving"));
int result = chooser.showDialog(tabbedPane, "Select");
@@ -94,12 +96,12 @@ abstract class TabbedSaveAction extends AbstractAction implements Iterable<TextF
}
else
{
- JOptionPane.showMessageDialog(tabbedPane, "Could not write to parent directory", "Invalid Parent Directory", JOptionPane.ERROR_MESSAGE);
+ JOptionPane.showMessageDialog(tabbedPane, _("Could not write to parent directory"), _("Invalid Parent Directory"), JOptionPane.ERROR_MESSAGE);
}
}
else
{
- JOptionPane.showMessageDialog(tabbedPane, "Could not access parent directory", "Invalid Parent Directory", JOptionPane.ERROR_MESSAGE);
+ JOptionPane.showMessageDialog(tabbedPane, _("Could not access parent directory"), _("Invalid Parent Directory"), JOptionPane.ERROR_MESSAGE);
}
}
}
diff --git a/translations/en_GB.po b/translations/en_GB.po
new file mode 100644
index 0000000..9413715
--- /dev/null
+++ b/translations/en_GB.po
@@ -0,0 +1,209 @@
+#java-format
+msgid "{0} is not between {1} and {2}."
+msgstr "{0} is not between {1} and {2}."
+msgid "Already iterated"
+msgstr "Already iterated"
+msgid "An error occurred while calling "
+msgstr "An error occurred while calling "
+msgid "Array index out of bounds, paofs={0}, pabuf.length={1}, buf.length={2}."
+msgstr "Array index out of bounds, paofs={0}, pabuf.length={1}, buf.length={2}."
+msgid "Arrays must not exceed "
+msgstr "Arrays must not exceed "
+msgid "Async call has not had a reply"
+msgstr "Async call has not had a reply"
+msgid "Bus address is blank"
+msgstr "Bus address is blank"
+msgid "Bus address is invalid: "
+msgstr "Bus address is invalid: "
+msgid "Cannot Resolve Session Bus Address"
+msgstr "Cannot Resolve Session Bus Address"
+msgid "Cannot watch for signals based on well known bus name as source, only unique names."
+msgstr "Cannot watch for signals based on well known bus name as source, only unique names."
+msgid "Can't wrap {0} in an unqualified Variant ({1})."
+msgstr "Can't wrap {0} in an unqualified Variant ({1})."
+msgid "Can't wrap a multi-valued type in a Variant: "
+msgstr "Can't wrap a multi-valued type in a Variant: "
+msgid "Can't wrap multiple or no types in a Variant: "
+msgstr "Can't wrap multiple or no types in a Variant: "
+msgid "Can't wrap Null in a Variant"
+msgstr "Can't wrap Null in a Variant"
+msgid "Connection has already sent a Hello message"
+msgstr "Connection has already sent a Hello message"
+msgid "Could not access parent directory for "
+msgstr "Could not access parent directory for "
+msgid "Could not find an interface to cast to"
+msgstr "Could not find an interface to cast to"
+msgid "Could not load Dbus information for "
+msgstr "Could not load Dbus information for "
+msgid "DBusInterfaces cannot be declared outside a package"
+msgstr "DBusInterfaces cannot be declared outside a package"
+msgid "DBusInterfaces must be defined in a package."
+msgstr "DBusInterfaces must be defined in a package."
+msgid "Disconnected"
+msgstr "Disconnected"
+msgid "ERROR: Could not find introspection file: "
+msgstr "ERROR: Could not find introspection file: "
+msgid "Error deserializing message: number of parameters didn't match receiving signature"
+msgstr "Error deserializing message: number of parameters didn't match receiving signature"
+msgid "Error during parser init: "
+msgstr "Error during parser init: "
+msgid "Error Executing Method {0}.{1}: {2}"
+msgstr "Error Executing Method {0}.{1}: {2}"
+msgid "ERROR: Expected {0}, got {1}, failed."
+msgstr "ERROR: Expected {0}, got {1}, failed."
+msgid "ERROR: Failed to get introspection data"
+msgstr "ERROR: Failed to get introspection data"
+msgid "ERROR: Failure in DBus Communications: "
+msgstr "ERROR: Failure in DBus Communications: "
+msgid "ERROR: Interface name was blank, failed"
+msgstr "ERROR: Interface name was blank, failed"
+msgid "ERROR: Unknown node: "
+msgstr "ERROR: Unknown node: "
+msgid "ERROR: Unknown option: "
+msgstr "ERROR: Unknown option: "
+msgid "Exporting non-exportable parameterized type "
+msgstr "Exporting non-exportable parameterized type "
+msgid "Exporting non-exportable type "
+msgstr "Exporting non-exportable type "
+msgid "Failed to add signal parameters: "
+msgstr "Failed to add signal parameters: "
+msgid "Failed to auth"
+msgstr "Failed to auth"
+msgid "Failed to connect to bus "
+msgstr "Failed to connect to bus "
+msgid "Failed to construct D-Bus type: "
+msgstr "Failed to construct D-Bus type: "
+msgid "Failed to construct outgoing method call: "
+msgstr "Failed to construct outgoing method call: "
+msgid "Failed to create proxy object for {0} exported by {1}. Reason: {2}"
+msgstr "Failed to create proxy object for {0} exported by {1}. Reason: {2}"
+msgid "Failed to create proxy object for {0}; reason: {1}."
+msgstr "Failed to create proxy object for {0}; reason: {1}."
+msgid "Failed to parse DBus type signature: "
+msgstr "Failed to parse DBus type signature: "
+msgid "Failed to parse DBus type signature: {0} ({1})."
+msgstr "Failed to parse DBus type signature: {0} ({1})."
+msgid "Failed to register bus name"
+msgstr "Failed to register bus name"
+msgid "Failure in de-serializing message: "
+msgstr "Failure in de-serializing message: "
+msgid "Introspected interface name exceeds 255 characters. Cannot export objects of type "
+msgstr "Introspected interface name exceeds 255 characters. Cannot export objects of type "
+msgid "Introspected method name exceeds 255 characters. Cannot export objects with method "
+msgstr "Introspected method name exceeds 255 characters. Cannot export objects with method "
+msgid "Introspected signal name exceeds 255 characters. Cannot export objects with signals of type "
+msgstr "Introspected signal name exceeds 255 characters. Cannot export objects with signals of type "
+msgid "Invalid bus name"
+msgstr "Invalid bus name"
+msgid "Invalid bus name: "
+msgstr "Invalid bus name: "
+msgid "Invalid bus name: null"
+msgstr "Invalid bus name: null"
+msgid "Invalid Bus Type: "
+msgstr "Invalid Bus Type: "
+msgid "Invalid Command "
+msgstr "Invalid Command "
+msgid "Invalid object path: "
+msgstr "Invalid object path: "
+msgid "Invalid object path: null"
+msgstr "Invalid object path: null"
+msgid "Invalid Parent Directory"
+msgstr "Invalid Parent Directory"
+msgid "Invalid type for match rule: "
+msgstr "Invalid type for match rule: "
+msgid " is not a basic type"
+msgstr " is not a basic type"
+msgid " is not an object provided by this process."
+msgstr " is not an object provided by this process."
+msgid "Map must have 2 parameters"
+msgstr "Map must have 2 parameters"
+msgid "Message Failed to Send: "
+msgstr "Message Failed to Send: "
+msgid "Message type {0} unsupported"
+msgstr "Message type {0} unsupported"
+msgid "Multi-valued array types not permitted"
+msgstr "Multi-valued array types not permitted"
+msgid "Must Specify an Object Path"
+msgstr "Must Specify an Object Path"
+msgid "Must specify destination, path and function name to MethodCalls."
+msgstr "Must specify destination, path and function name to MethodCalls."
+msgid "Must specify error name to Errors."
+msgstr "Must specify error name to Errors."
+msgid "Must specify object path, interface and signal name to Signals."
+msgstr "Must specify object path, interface and signal name to Signals."
+msgid "No reply within specified time"
+msgstr "No reply within specified time"
+msgid "Not A DBus Interface"
+msgstr "Not A DBus Interface"
+msgid "Not A DBus Signal"
+msgstr "Not A DBus Signal"
+msgid "Not an array"
+msgstr "Not an array"
+msgid "Not An Expected Convertion type from {0} to {1}"
+msgstr "Not An Expected Convertion type from {0} to {1}"
+msgid "Not an object exported by this connection and no remote specified"
+msgstr "Not an object exported by this connection and no remote specified"
+msgid "Not a primitive type"
+msgstr "Not a primitive type"
+msgid "Not a wrapper type"
+msgstr "Not a wrapper type"
+msgid "Not Connected"
+msgstr "Not Connected"
+msgid "Not enough elements to create custom object from serialized data ({0} < {1})."
+msgstr "Not enough elements to create custom object from serialized data ({0} < {1})."
+msgid "No transport present"
+msgstr "No transport present"
+msgid "Object already exported"
+msgstr "Object already exported"
+msgid "Primative array being sent as non-primative array."
+msgstr "Primative array being sent as non-primative array."
+msgid "Processing DBus for "
+msgstr "Processing DBus for "
+msgid "Protocol version {0} is unsupported"
+msgstr "Protocol version {0} is unsupported"
+msgid "Return type of Object[] cannot be introspected properly"
+msgstr "Return type of Object[] cannot be introspected properly"
+msgid "Save "
+msgstr "Save "
+msgid "Save Failed"
+msgstr "Save Failed"
+msgid "Select parent directory for saving"
+msgstr "Select parent directory for saving"
+msgid "Sending message failed"
+msgstr "Sending message failed"
+msgid "Serializable classes must implement a deserialize method"
+msgstr "Serializable classes must implement a deserialize method"
+msgid "Serializable classes must serialize to native DBus types"
+msgstr "Serializable classes must serialize to native DBus types"
+msgid "Signals must be declared as a member of a class implementing DBusInterface which is the member of a package."
+msgstr "Signals must be declared as a member of a class implementing DBusInterface which is the member of a package."
+msgid "Spurious reply. No message with the given serial id was awaiting a reply."
+msgstr "Spurious reply. No message with the given serial id was awaiting a reply."
+msgid "System does not support UTF-8 encoding"
+msgstr "System does not support UTF-8 encoding"
+msgid "The method `{0}.{1}' does not exist on this object."
+msgstr "The method `{0}.{1}' does not exist on this object."
+msgid "The name `{0}' does not exist"
+msgstr "The name `{0}' does not exist"
+msgid "This service does not support "
+msgstr "This service does not support "
+msgid "Trying to marshall to unconvertable type (from {0} to {1})."
+msgstr "Trying to marshall to unconvertable type (from {0} to {1})."
+msgid "Try saving other files?"
+msgstr "Try saving other files?"
+msgid "Underlying transport returned EOF"
+msgstr "Underlying transport returned EOF"
+msgid "unknown address type "
+msgstr "unknown address type "
+msgid "Waiting for: "
+msgstr "Waiting for: "
+msgid "Wrong return type (failed to de-serialize correct types: {0} )"
+msgstr "Wrong return type (failed to de-serialize correct types: {0} )"
+msgid "Wrong return type (failed to de-serialize correct types: {0})"
+msgstr "Wrong return type (failed to de-serialize correct types: {0})"
+msgid "Wrong return type (got void, expected a value)"
+msgstr "Wrong return type (got void, expected a value)"
+msgid "Wrong return type (not expecting Tuple)"
+msgstr "Wrong return type (not expecting Tuple)"
+msgid "You must send a Hello message"
+msgstr "You must send a Hello message"