public class JaxoDictionary
extends java.lang.Object
Constructor and Description |
---|
JaxoDictionary(java.lang.Class c)
Create for the given class.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
label(java.lang.String key)
Translate 'key' as a label (typically, by appending ": " to the
default translation).
|
java.util.Locale |
locale()
Locale corresponding to the current language.
|
java.lang.String |
message(java.lang.String key,
java.lang.Object argument)
Translates the given string into the current default language,
interpolating a single argument.
|
java.lang.String |
message(java.lang.String key,
java.lang.Object[] arguments)
Translates the given string into the current default language,
interpolating arguments.
|
java.lang.String |
message(java.lang.String key,
java.lang.Object argument1,
java.lang.Object argument2)
Translates the given string into the current default language,
interpolating two arguments.
|
java.lang.String |
value(java.lang.String key)
Translates the given string into the current default language.
|
public JaxoDictionary(java.lang.Class c)
c
- The class to register.public java.util.Locale locale()
public java.lang.String label(java.lang.String key)
key
- The key to translate.public java.lang.String value(java.lang.String key)
key
- The key to translate.public java.lang.String message(java.lang.String key, java.lang.Object argument)
message(String,Object[])
with second argument
new Object[] { argument }
.key
- The key to translate.argument
- An object.public java.lang.String message(java.lang.String key, java.lang.Object argument1, java.lang.Object argument2)
message(String,Object[])
with second argument
new Object[] { argument1, argument2 }
.key
- The key to translate.argument1
- A first object.argument2
- A second object.public java.lang.String message(java.lang.String key, java.lang.Object[] arguments)
If arguments
is not empty, the translation of
key
is used as a
MessageFormat
pattern, the arguments
array is then used as the argument for
Format.format(Object)
.
See the language.properties for notes on the parsing of MessageFormat patterns.
If however, arguments
is empty, the key
translation is not parsed as MessageFormat pattern (That way, the
message
methods can be used generically.)
By convention, the keys for MessageFormat pattern (and only
them) contain percentage signs, followed by a number (starting from zero,
as MessageFormat), to denote the occurrence of arguments (e.g.
JaxoIO.read%0ReadFailed=File "{0}" could not be read.
).
Then:
message("JaxoIO.read%0ReadFailed", new Object[] { a, b});
can be seen to be incorrect.
key
- The key to translate.arguments
- An array of objects (arguments for MessageFormat).Licensed under GPL. For more information, see http://jaxodraw.sourceforge.net/license.html or the LICENSE file in the jaxodraw distribution.