public class Localiser extends Object
The DataNucleus system is internationalisable hence messages (to log files or exceptions) can
be displayed in multiple languages. Currently DataNucleus contains localisation files in the
default locale (English), but can be extended easily by adding localisationfiles in languages
such as Spanish, French, etc. The internationalisation operates around the
org.datanucleus.util.Localiser class that is responsible for generating the
messages in the specified locale. Each class needs to instantiate a Localiser
If you want to extend this to another language and contribute the files for your language you need to find all files "Localisation.properties" and provide an alternative variant.
Note that the second argument used in constructing the Localiser is important for OSGi. It has to be a class in the same OSGi bundle as the Localisation.properties file
You will find alternates in Spanish already present named "Localisation_es.properties", so if you wanted to create a French localisation then provide "Localisation_fr.properties".
Modifier and Type | Method and Description |
---|---|
static Localiser |
getInstance(String bundle_name,
ClassLoader class_loader)
Accessor for a helper instance for a bundle.
|
String |
msg(boolean includeCode,
String messageKey)
Message formatter for an internationalised message.
|
String |
msg(boolean includeCode,
String messageKey,
long arg)
Message formatter with one argument passed in that will be embedded in an internationalised message.
|
String |
msg(boolean includeCode,
String messageKey,
Object arg1)
Message formatter with one argument passed in that will be embedded in an internationalised message.
|
String |
msg(boolean includeCode,
String messageKey,
Object arg1,
Object arg2)
Message formatter with a series of arguments passed in that will be embedded in an internationalised message.
|
String |
msg(boolean includeCode,
String messageKey,
Object arg1,
Object arg2,
Object arg3)
Message formatter with a series of arguments passed in that will be embedded in an internationalised message.
|
String |
msg(boolean includeCode,
String messageKey,
Object arg1,
Object arg2,
Object arg3,
Object arg4)
Message formatter with a series of arguments passed in that will be embedded in an internationalised message.
|
String |
msg(boolean includeCode,
String messageKey,
Object arg1,
Object arg2,
Object arg3,
Object arg4,
Object arg5)
Message formatter with a series of arguments passed in that will be embedded in an internationalised message.
|
String |
msg(String messageKey)
Message formatter for an internationalised message.
|
String |
msg(String messageKey,
long arg)
Message formatter with one argument passed in that will be embedded in an internationalised message.
|
String |
msg(String messageKey,
Object arg1)
Message formatter with one argument passed in that will be embedded in an internationalised message.
|
String |
msg(String messageKey,
Object arg1,
Object arg2)
Message formatter with a series of arguments passed in that will be embedded in an internationalised message.
|
String |
msg(String messageKey,
Object arg1,
Object arg2,
Object arg3)
Message formatter with a series of arguments passed in that will be embedded in an internationalised message.
|
String |
msg(String messageKey,
Object arg1,
Object arg2,
Object arg3,
Object arg4)
Message formatter with a series of arguments passed in that will be embedded in an internationalised message.
|
String |
msg(String messageKey,
Object arg1,
Object arg2,
Object arg3,
Object arg4,
Object arg5)
Message formatter with a series of arguments passed in that will be embedded in an internationalised message.
|
static void |
setDisplayCodesInMessages(boolean display)
Method to allow turning on/off of display of error codes in messages.
|
static void |
setLanguage(String languageCode)
Convenience method to change the language of the resource bundles used by the localisers.
|
public static void setLanguage(String languageCode)
languageCode
- The new language codepublic static void setDisplayCodesInMessages(boolean display)
display
- Whether to display codespublic static Localiser getInstance(String bundle_name, ClassLoader class_loader)
bundle_name
- the name of the bundleclass_loader
- the class loader from which to load the resource
bundlepublic String msg(boolean includeCode, String messageKey)
includeCode
- Whether to include the code in the messagemessageKey
- the message keypublic String msg(boolean includeCode, String messageKey, long arg)
includeCode
- Whether to include the code in the messagemessageKey
- the message keyarg
- the argumentpublic String msg(boolean includeCode, String messageKey, Object arg1)
includeCode
- Whether to include the code in the messagemessageKey
- the message keyarg1
- the first argumentpublic String msg(boolean includeCode, String messageKey, Object arg1, Object arg2)
includeCode
- Whether to include the code in the messagemessageKey
- the message keyarg1
- the first argumentarg2
- the second argumentpublic String msg(boolean includeCode, String messageKey, Object arg1, Object arg2, Object arg3)
includeCode
- Whether to include the code in the messagemessageKey
- the message keyarg1
- the first argumentarg2
- the second argumentarg3
- the third argumentpublic String msg(boolean includeCode, String messageKey, Object arg1, Object arg2, Object arg3, Object arg4)
includeCode
- Whether to include the code in the messagemessageKey
- the message keyarg1
- the first argumentarg2
- the second argumentarg3
- the third argumentarg4
- the third argumentpublic String msg(boolean includeCode, String messageKey, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5)
includeCode
- Whether to include the code in the messagemessageKey
- the message keyarg1
- the first argumentarg2
- the second argumentarg3
- the third argumentarg4
- the third argumentarg5
- the third argumentpublic String msg(String messageKey)
messageKey
- the message keypublic String msg(String messageKey, Object arg1)
messageKey
- the message keyarg1
- the first argumentpublic String msg(String messageKey, Object arg1, Object arg2)
messageKey
- the message keyarg1
- the first argumentarg2
- the second argumentpublic String msg(String messageKey, Object arg1, Object arg2, Object arg3)
messageKey
- the message keyarg1
- the first argumentarg2
- the second argumentarg3
- the third argumentpublic String msg(String messageKey, Object arg1, Object arg2, Object arg3, Object arg4)
messageKey
- the message keyarg1
- the first argumentarg2
- the second argumentarg3
- the third argumentarg4
- the third argumentpublic String msg(String messageKey, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5)
messageKey
- the message keyarg1
- the first argumentarg2
- the second argumentarg3
- the third argumentarg4
- the third argumentarg5
- the third argumentCopyright © 2014. All Rights Reserved.