public final class JaxoLanguage
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BUNDLE_NAME
The bundle name used for language lookups.
|
static java.lang.String |
ENGLISH
English.
|
static java.lang.String |
FRENCH
French.
|
static java.lang.String |
GERMAN
German.
|
static java.lang.String |
ITALIAN
Italian.
|
static java.lang.String |
SPANISH
Spanish.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
bundleMessage(java.lang.String key,
java.lang.String bundleId,
java.lang.Object argument)
Translates the given string into the current default language.
|
static java.lang.String |
bundleMessage(java.lang.String key,
java.lang.String bundleId,
java.lang.Object[] arguments)
Translates the given string.
|
static java.lang.String |
bundleMessage(java.lang.String key,
java.lang.String bundleId,
java.lang.Object argument1,
java.lang.Object argument2)
Translates the given string into the current default language.
|
static java.lang.String |
bundleTranslate(java.lang.String akey,
java.lang.String abundleId)
Translates the given string into the current default language.
|
static java.lang.String |
getLanguageFor(int mode)
Returns the language string for the given mode.
|
static java.lang.String[] |
knownLanguages()
Returns the languages known by this version of JaxoDraw.
|
static java.lang.String |
label(java.lang.String key)
Translate 'key' as a label (typically, by appending ": " to the
default translation).
|
static void |
languageChanged(java.lang.String language)
Updates the current locale and associated language bundle.
|
static java.util.Locale |
locale()
Locale corresponding to the current language.
|
static 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.
|
static java.lang.String |
message(java.lang.String key,
java.lang.Object[] arguments)
Translates the given string into the current default language,
interpolating arguments.
|
static 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.
|
static void |
registerBundle(java.lang.Class c)
Register a custom bundle for the class c.
|
static void |
registerBundle(java.lang.Class c,
JaxoDictionary d)
Register a custom bundle for the class c,
('c' may also be in the core).
|
static void |
removeBundle(java.lang.Class c)
Removes the previously registered bundle for the class c.
|
static java.lang.String |
translate(java.lang.String key)
Translates the given string into the current default language.
|
public static final java.lang.String ENGLISH
public static final java.lang.String GERMAN
public static final java.lang.String FRENCH
public static final java.lang.String ITALIAN
public static final java.lang.String SPANISH
public static final java.lang.String BUNDLE_NAME
public static void registerBundle(java.lang.Class c)
c.getName()/resources/properties
(using the class
loader of 'c') where dots in the class name are replaced by '/'.c
- The class for which a bundle should be registered.public static void registerBundle(java.lang.Class c, JaxoDictionary d)
c
- The class for which a bundle should be registered.d
- The dictionary to bind to the given class.registerBundle(Class)
public static void removeBundle(java.lang.Class c)
c
- The class for which a bundle should be removed.public static void languageChanged(java.lang.String language)
language
- The new language.public static java.util.Locale locale()
public static java.lang.String label(java.lang.String key)
key
- The key to translate.public static 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 static java.lang.String bundleMessage(java.lang.String key, java.lang.String bundleId, java.lang.Object argument)
key
- The key to translate.bundleId
- An identifier for an external language bundle,
if null, the default JaxoDraw bundle will be used.argument
- An object.message(String,Object)
public static 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 static java.lang.String bundleMessage(java.lang.String key, java.lang.String bundleId, java.lang.Object argument1, java.lang.Object argument2)
key
- The key to translate.bundleId
- An identifier for an external language bundle,
if null, the default JaxoDraw bundle will be used.argument1
- A first object.argument2
- A second object.message(String,Object,Object)
public static 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).public static java.lang.String bundleMessage(java.lang.String key, java.lang.String bundleId, java.lang.Object[] arguments)
key
- The key to translate.bundleId
- An identifier for an external language bundle,
if null, the default JaxoDraw bundle will be used.arguments
- An array of objects (arguments for MessageFormat).message(String,Object[])
public static java.lang.String translate(java.lang.String key)
key
- The key to translate.public static java.lang.String bundleTranslate(java.lang.String akey, java.lang.String abundleId)
akey
- The key to translate.abundleId
- An identifier for an external language bundle,
if null, the default JaxoDraw bundle will be used.public static java.lang.String getLanguageFor(int mode)
mode
- The language mode as defined in JaxoConstants.public static java.lang.String[] knownLanguages()
Licensed under GPL. For more information, see http://jaxodraw.sourceforge.net/license.html or the LICENSE file in the jaxodraw distribution.