|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.jaxodraw.util.JaxoLanguage
public final class JaxoLanguage
A convenience class to deal with I18N issues.
Field Summary | |
---|---|
static String |
ENGLISH
English. |
static String |
FRENCH
French. |
static String |
GERMAN
German. |
static String |
ITALIAN
Italian. |
static String |
SPANISH
Spanish. |
Method Summary | |
---|---|
static String |
bundleMessage(String key,
String bundleId,
Object argument)
Translates the given string into the current default language. |
static String |
bundleMessage(String key,
String bundleId,
Object[] arguments)
Translates the given string. |
static String |
bundleMessage(String key,
String bundleId,
Object argument1,
Object argument2)
Translates the given string into the current default language. |
static String |
bundleTranslate(String akey,
String abundleId)
Translates the given string into the current default language. |
static String |
getLanguageFor(int mode)
Returns the language string for the given mode. |
static String[] |
knownLanguages()
Returns the languages known by this version of JaxoDraw. |
static String |
label(String key)
Translate 'key' as a label (typically, by appending ": " to the default translation). |
static void |
languageChanged(String language)
Updates the current locale and associated language bundle. |
static Locale |
locale()
Locale corresponding to the current language. |
static String |
message(String key,
Object argument)
Translates the given string into the current default language, interpolating a single argument. |
static String |
message(String key,
Object[] arguments)
Translates the given string into the current default language, interpolating arguments. |
static String |
message(String key,
Object argument1,
Object argument2)
Translates the given string into the current default language, interpolating two arguments. |
static void |
registerBundle(Class<?> c)
Register a custom bundle for the class c. |
static void |
registerBundle(Class<?> c,
JaxoDictionary d)
Register a custom bundle for the class c, ('c' may also be in the core). |
static void |
removeBundle(Class<?> c)
Removes the previously registered bundle for the class c. |
static String |
translate(String key)
Translates the given string into the current default language. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ENGLISH
public static final String GERMAN
public static final String FRENCH
public static final String ITALIAN
public static final String SPANISH
Method Detail |
---|
public static void registerBundle(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(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(Class<?> c)
c
- The class for which a bundle should be removed.public static void languageChanged(String language)
language
- The new language.public static Locale locale()
public static String label(String key)
key
- The key to translate.
public static String message(String key, Object argument)
message(String,Object[])
with second argument
new Object[] { argument }
.
key
- The key to translate.argument
- An object.
public static String bundleMessage(String key, String bundleId, 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 String message(String key, Object argument1, 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 String bundleMessage(String key, String bundleId, Object argument1, 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 String message(String key, 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 String bundleMessage(String key, String bundleId, 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 String translate(String key)
key
- The key to translate.
public static String bundleTranslate(String akey, 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 String getLanguageFor(int mode)
mode
- The language mode as defined in JaxoConstants.
public static String[] knownLanguages()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |