Package org.nuiton.i18n.init
Class UserI18nInitializer
java.lang.Object
org.nuiton.i18n.init.I18nInitializer
org.nuiton.i18n.init.DefaultI18nInitializer
org.nuiton.i18n.init.UserI18nInitializer
public class UserI18nInitializer extends DefaultI18nInitializer
Initializer which expose i18n resources in the
userDirectory, then
use resources from this user directories.- Since:
- 1.1
- Author:
- Tony Chemit - chemit@codelutin.com
-
Field Summary
Fields Modifier and Type Field Description protected DefaultI18nInitializerdelegatethe delegate initializer to obtain default i18n resources to put in user directory.protected java.io.FileuserDirectorythe user directory where to store the i18n resources.Fields inherited from class org.nuiton.i18n.init.DefaultI18nInitializer
BUNDLE_DEF_ENCODING, BUNDLE_DEF_LOCALES, BUNDLE_DEF_VERSION, bundleName, BUNDLES_FOR_LOCALE, DEFAULT_I18N_PATH, definitionURL, i18nPath, loader, UNIQUE_BUNDLE_DEF, UNIQUE_BUNDLE_ENTRYFields inherited from class org.nuiton.i18n.init.I18nInitializer
encoding, messageFormatter, missingKeyReturnNull -
Constructor Summary
Constructors Constructor Description UserI18nInitializer(java.io.File userDirectory, DefaultI18nInitializer delegate)UserI18nInitializer(java.lang.String i18nPath, java.io.File userDirectory, DefaultI18nInitializer delegate) -
Method Summary
Modifier and Type Method Description protected voidcreateUserI18nLayout(java.io.File directory)Creates the user i18n structure or fill it if required.DefaultI18nInitializergetDelegate()java.nio.charset.CharsetgetEncoding()Get theCharsetencoding used for i18nPropertiesfile loading.I18nMessageFormattergetMessageFormatter()Get theI18nMessageFormatterto use on each i18n message translation.java.io.FilegetUserDirectory()I18nBundle[]resolvBundles()Resolv the bundles.voidsetEncoding(java.nio.charset.Charset encoding)Setencodingto use for i18nPropertiesfile loading.voidsetMessageFormatter(I18nMessageFormatter messageFormatter)SetmessageFormatterto use on each i18n message translation.voidupdateUserI18nLayout(java.io.File directory, I18nBundle[] bundles)Hook to update the user i18n structure.Methods inherited from class org.nuiton.i18n.init.DefaultI18nInitializer
getBundleName, getDefinitionURL, getI18nPath, getLoader, getResourceURL, resolvDefinition, resolvURLs, setI18nPath, setLoaderMethods inherited from class org.nuiton.i18n.init.I18nInitializer
isMissingKeyReturnNull, resolvBundles, setMissingKeyReturnNull
-
Field Details
-
userDirectory
protected final java.io.File userDirectorythe user directory where to store the i18n resources. -
delegate
the delegate initializer to obtain default i18n resources to put in user directory.
-
-
Constructor Details
-
UserI18nInitializer
public UserI18nInitializer(java.io.File userDirectory, DefaultI18nInitializer delegate) throws java.lang.NullPointerException- Throws:
java.lang.NullPointerException
-
UserI18nInitializer
public UserI18nInitializer(java.lang.String i18nPath, java.io.File userDirectory, DefaultI18nInitializer delegate) throws java.lang.NullPointerException- Throws:
java.lang.NullPointerException
-
-
Method Details
-
getUserDirectory
public java.io.File getUserDirectory() -
getDelegate
-
getEncoding
public java.nio.charset.Charset getEncoding()Description copied from class:I18nInitializerGet theCharsetencoding used for i18nPropertiesfile loading.- Overrides:
getEncodingin classI18nInitializer- Returns:
- encoding to use
-
setEncoding
public void setEncoding(java.nio.charset.Charset encoding)Description copied from class:I18nInitializerSetencodingto use for i18nPropertiesfile loading.- Overrides:
setEncodingin classI18nInitializer- Parameters:
encoding- Charset encoding to use
-
getMessageFormatter
Description copied from class:I18nInitializerGet theI18nMessageFormatterto use on each i18n message translation.- Overrides:
getMessageFormatterin classI18nInitializer- Returns:
- formatter to use
-
setMessageFormatter
Description copied from class:I18nInitializerSetmessageFormatterto use on each i18n message translation.- Overrides:
setMessageFormatterin classI18nInitializer- Parameters:
messageFormatter- I18nMessageFormatter to use
-
resolvBundles
Description copied from class:I18nInitializerResolv the bundles.- Overrides:
resolvBundlesin classDefaultI18nInitializer- Returns:
- the bundles detected
- Throws:
java.lang.Exception- if any pb while getting bundles
-
createUserI18nLayout
protected void createUserI18nLayout(java.io.File directory) throws java.lang.ExceptionCreates the user i18n structure or fill it if required. will use the default initializer to obtain i18n resources from default system, then copy them to the user directory.- Parameters:
directory- the directory where to export i18n resources- Throws:
java.lang.Exception- if any pb
-
updateUserI18nLayout
Hook to update the user i18n structure. If you wants to do something specific, overriddes this method.- Parameters:
directory- the user directory where are i18n resourcesbundles- the user i18n bundles
-