|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnl.knowledgeplaza.util.Internationalization
public class Internationalization
Translate a id to a locale specific value by searching multiple locations in this order:
- Classname.internationalization.xml
- internationalization.xml in the package of the class
- internationalization.xml anywhere on the classpath (TODO: all internationalization.xml files anywhere in the classpath, random order)
- resource bundle of the class (old style resources)
Each translation consists of thee parameters:
- context, the object where in the translation takes place
- id, the id of the translation
- locale, for which is translated
The context is used to determine which internationalization.xml files should be examined for the indicated id / locale.
But if the examined internationalization.xml file is more generic (package or classpath level), it is allowed to append the context to the id like: id@context.
In this way the context can always be a factor when searching for an id.
Usage will show that it is convenient to have some more technical translations place in these files also, for example a color.
These translations may / should / could be placed in a ConfigurationProperties setup, but that would make things not easier to maintain.
So "language-less" translates are also supported, and also its shorter form: translation nodes with a translate attribute.
Some examples:
) must be inserted into the ending XML, use this:
...
| Constructor Summary | |
|---|---|
Internationalization()
|
|
| Method Summary | |
|---|---|
static java.util.List |
generateLocalePermutations(java.util.Locale locale)
Translate |
static Internationalization |
get()
|
java.util.Locale |
getDefaultLocale()
DefaultLocale |
static Internationalization |
getInternationalization()
Singleton |
void |
setDefaultLocale(java.util.Locale value)
|
java.lang.String |
translate(java.lang.Object context,
java.lang.String id)
Translate, this method tries to find files where the translation could be, based on the context. |
java.lang.String |
translate(java.lang.Object context,
java.lang.String id,
java.util.Locale locale)
Translate, this method tries to find files where the translation could be, based on the context. |
java.lang.String |
translate(java.lang.Object context,
java.lang.String id,
java.util.Locale locale,
java.lang.String defaultTranslation)
Translate, this method tries to find files where the translation could be, based on the context. |
boolean |
translateExists(java.lang.Object context,
java.lang.String id)
Translate, this method tries to find files where the translation could be, based on the context. |
boolean |
translateExists(java.lang.Object context,
java.lang.String id,
java.util.Locale locale)
Translate, this method tries to find files where the translation could be, based on the context. |
boolean |
translateExists(java.lang.Object context,
java.lang.String id,
java.util.Locale locale,
java.lang.String defaultTranslation)
Translate, this method tries to find files where the translation could be, based on the context. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Internationalization()
| Method Detail |
|---|
public static Internationalization getInternationalization()
public static Internationalization get()
public java.util.Locale getDefaultLocale()
public void setDefaultLocale(java.util.Locale value)
public java.lang.String translate(java.lang.Object context,
java.lang.String id)
context - id -
public java.lang.String translate(java.lang.Object context,
java.lang.String id,
java.util.Locale locale)
context - id - localeId -
public java.lang.String translate(java.lang.Object context,
java.lang.String id,
java.util.Locale locale,
java.lang.String defaultTranslation)
context - id - localeId - defaultTranslation -
public boolean translateExists(java.lang.Object context,
java.lang.String id)
context - id -
public boolean translateExists(java.lang.Object context,
java.lang.String id,
java.util.Locale locale)
context - id - localeId -
public boolean translateExists(java.lang.Object context,
java.lang.String id,
java.util.Locale locale,
java.lang.String defaultTranslation)
context - id - localeId - defaultTranslation -
public static java.util.List generateLocalePermutations(java.util.Locale locale)
id - locale -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||