Package eu.woolplatform.utils.i18n
Class I18nLoader
- java.lang.Object
-
- eu.woolplatform.utils.i18n.I18nLoader
-
public class I18nLoader extends Object
This class can load i18n message resources and keep them in memory for later reference. You can get a resource set withgetI18n(), which will try to load the set at the first call. It usesI18nResourceFinderto find a matching properties file, in .properties format or .xml format. Note that a .properties file will be loaded as UTF-8.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description I18ngetI18n(String baseName, List<Locale> locales, boolean honorifics, Class<?> loadClass)Returns the i18n message resource for the specified parameters.I18ngetI18n(String baseName, Locale locale, boolean honorifics, Class<?> loadClass)Returns the i18n message resource for the specified parameters.static I18nLoadergetInstance()Returns the i18n loader.
-
-
-
Method Detail
-
getInstance
public static I18nLoader getInstance()
Returns the i18n loader.- Returns:
- the i18n loader
-
getI18n
public I18n getI18n(String baseName, Locale locale, boolean honorifics, Class<?> loadClass) throws RuntimeException
Returns the i18n message resource for the specified parameters. If the resource has not been loaded yet, it will be loaded now (.properties or .xml) and then saved in memory. Note that a .properties file will be loaded as UTF-8. For more details seeI18nResourceFinder.- Parameters:
baseName- the base namelocale- the preferred localehonorifics- true if the resource should use honorifics, false otherwiseloadClass- the resource loading class or null- Returns:
- the message resource
- Throws:
RuntimeException- if no matching resource is found, or a matching resource can't be loaded
-
getI18n
public I18n getI18n(String baseName, List<Locale> locales, boolean honorifics, Class<?> loadClass) throws RuntimeException
Returns the i18n message resource for the specified parameters. If the resource has not been loaded yet, it will be loaded now (.properties or .xml) and then saved in memory. Note that a .properties file will be loaded as UTF-8. For more details seeI18nResourceFinder.- Parameters:
baseName- the base namelocales- the preferred locales (at least one)honorifics- true if the resource should use honorifics, false otherwiseloadClass- the resource loading class or null- Returns:
- the message resource
- Throws:
RuntimeException- if no matching resource is found, or a matching resource can't be loaded
-
-