public enum I18nHelper extends java.lang.Enum<I18nHelper> implements Helper<java.lang.String>
The Java implementation use ResourceBundle
.
The JavaScript version use the I18n library.
ResourceBundle
are converted to JavaScript code.
ResourceBundle
Enum Constant and Description |
---|
i18n
A helper built on top of
ResourceBundle . |
i18nJs
Translate a
ResourceBundle into JavaScript code. |
Modifier and Type | Method and Description |
---|---|
void |
setDefaultBundle(java.lang.String bundle)
Set the default bundle's name.
|
void |
setDefaultLocale(java.util.Locale locale)
Set the default locale.
|
void |
setSource(I18nSource source)
Set the message source.
|
static I18nHelper |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static I18nHelper[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final I18nHelper i18n
A helper built on top of ResourceBundle
. A ResourceBundle
is the most well
known mechanism for internationalization (i18n).
hello=Hola
{{i18n "hello"}}
Will result in: Hola
{{i18n "hello" locale="es_AR"}}
{{i18n "hello" bundle="myMessages"}}
hello=Hola {0}!
{{i18n "hello" "Handlebars.java"}}
ResourceBundle
public static final I18nHelper i18nJs
Translate a ResourceBundle
into JavaScript code. The generated code assume you added
the I18n
It converts message patterns like: Hi {0}
into Hi {{arg0}}
. This make
possible to the I18n JS library to interpolate variables.
Note: make sure you include I18n in your application. Otherwise, the generated code will fail.
Usage:
{{i18nJs locale?}}If locale argument is present it will translate that locale to JavaScript. Otherwise, the default locale.
public static I18nHelper[] values()
for (I18nHelper c : I18nHelper.values()) System.out.println(c);
public static I18nHelper valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullpublic void setSource(I18nSource source)
source
- The message source. Required.public void setDefaultBundle(java.lang.String bundle)
bundle
- The default's bundle name. Required.public void setDefaultLocale(java.util.Locale locale)
locale
- The default locale name. Required.Copyright © 2010 - 2020 Adobe. All Rights Reserved