|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.vostok.vaadin.addon.i18n.I18n
public class I18n
i18n is a centralized class to access translation, used internally by dialog, i18nbutton,etc...
You can add your own bundles, whom can provide new locales, override existing ones or just add application specific resources.
Every time you look for a key, I18n process from the most recent bundle to default one. Look up end when a key/value for the requested locale is found. If not, it returns I18n.UNKNOW (def, empty).
Default language set to user locale ( UI.getCurrent().getLocale() )
German translation by Julie Rabier.
1.1.2 : corrected default resource bundle
See sample at http://vaadin.vostoksystem.eu
Constructor Summary | |
---|---|
I18n()
|
Method Summary | |
---|---|
static void |
addBundlePath(java.lang.String path)
Extend or override resource bundle. |
static java.lang.String[] |
getBundlePath()
return local bundle |
static java.lang.String |
getString(java.lang.String key)
Translation for key key in user locale. |
static java.lang.String |
getString(java.lang.String key,
java.util.Locale locale)
Translation for key key with locale locale . |
static java.lang.String |
parse(java.lang.String key,
java.util.Locale locale,
java.lang.String... token)
same as getString but replace any token in the source string with token Token's source format is {0}, {1}, etc... {} is an alias for {0]. |
static java.lang.String |
parse(java.lang.String key,
java.util.Locale locale,
java.lang.String replace,
java.lang.String... token)
same as getString but replace any token in the source string with token Token's source format is {0}, {1}, etc... {} is an alias for {0]. |
static java.lang.String |
parse(java.lang.String key,
java.lang.String... token)
same as getString but replace any token in the source string with token Token's source format is {0}, {1}, etc... {} is an alias for {0]. |
static void |
removeBundlePath(java.lang.String path)
remove bundle. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public I18n()
Method Detail |
---|
public static void addBundlePath(java.lang.String path) throws java.util.MissingResourceException
path
- path to new resource file, set null, to clear user bundle
java.util.MissingResourceException
- if bundle doesn't existpublic static java.lang.String[] getBundlePath()
String[]
list of bundle, can be empty but newer null.public static void removeBundlePath(java.lang.String path)
path
- bundle
to remove. if doens't exit, does nothingpublic static java.lang.String getString(java.lang.String key)
key
in user locale.
key
- i18n key
String
for key. In user locale, or english, or "unknow" if key not foundpublic static java.lang.String getString(java.lang.String key, java.util.Locale locale)
key
with locale locale
.
key
- i18n key.locale
- locale to use
String
for key. In user locale, or english, or UNKNOW if key not found or nullpublic static java.lang.String parse(java.lang.String key, java.lang.String... token)
token[0]
is {0}, token[1]
is {1} and so on.
key
- i18n key.token
- String[]
of token(s). optional
String
or UNKNOW if key not found or nullpublic static java.lang.String parse(java.lang.String key, java.util.Locale locale, java.lang.String... token)
token[0]
is {0}, token[1]
is {1} and so on.
key
- i18n key.locale
- locale to usetoken
- String[]
of token(s). optional
String
or UNKNOW if key not found or nullpublic static java.lang.String parse(java.lang.String key, java.util.Locale locale, java.lang.String replace, java.lang.String... token)
token[0]
is {0}, token[1]
is {1} and so on.
key
- locale
- locale to usereplace
- String
to subtstitute unkonw token. default to empty stringtoken
- String[]
of token(s). optional
String
or UNKNOW if key not found or null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |