Enum I18nHelper
- All Implemented Interfaces:
Helper<String>,Serializable,Comparable<I18nHelper>,java.lang.constant.Constable
Implementation of i18n helper for Java and JavaScript.
The Java implementation use ResourceBundle.
The JavaScript version use the I18n library.
ResourceBundle are converted to JavaScript code.
- Since:
- 0.9.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionA helper built on top ofResourceBundle.Translate aResourceBundleinto JavaScript code. -
Method Summary
Modifier and TypeMethodDescriptionvoidsetCharset(Charset charset) Set the charset to use.voidsetDefaultBundle(String bundle) Set the default bundle's name.voidsetDefaultLocale(Locale locale) Set the default locale.voidsetSource(I18nSource source) Set the message source.static I18nHelperReturns 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.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
i18n
A helper built on top of
ResourceBundle. AResourceBundleis the most well known mechanism for internationalization (i18n).messages.properties:
hello=Hola
Basic Usage:
{{i18n "hello"}}Will result in:
HolaUsing a locale:
{{i18n "hello" locale="es_AR"}}Using a different bundle:
{{i18n "hello" bundle="myMessages"}}Using a message format:
hello=Hola {0}!{{i18n "hello" "Handlebars.java"}}- Since:
- 0.9.0
- See Also:
-
i18nJs
Translate a
ResourceBundleinto JavaScript code. The generated code assume you added the I18nIt converts message patterns like:
Hi {0}intoHi {{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.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
setCharset
Set the charset to use. NotThreadSafe Make sure to call this method ONCE at start time.- Parameters:
charset- Charset. Required.
-
setSource
Set the message source. NotThreadSafe Make sure to call this method ONCE at start time.- Parameters:
source- The message source. Required.
-
setDefaultBundle
Set the default bundle's name. Default is: messages and this method let you override the default bundle's name to something else. NotThreadSafe Make sure to call this method ONCE at start time.- Parameters:
bundle- The default's bundle name. Required.
-
setDefaultLocale
Set the default locale. Default is system dependent and this method let you override the default bundle's name to something else. NotThreadSafe Make sure to call this method ONCE at start time.- Parameters:
locale- The default locale name. Required.
-