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 theuserDirectory
, 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 DefaultI18nInitializer
delegate
the delegate initializer to obtain default i18n resources to put in user directory.protected File
userDirectory
the 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_ENTRY
-
Fields inherited from class org.nuiton.i18n.init.I18nInitializer
encoding, messageFormatter, missingKeyReturnNull
-
-
Constructor Summary
Constructors Constructor Description UserI18nInitializer(File userDirectory, DefaultI18nInitializer delegate)
UserI18nInitializer(String i18nPath, File userDirectory, DefaultI18nInitializer delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
createUserI18nLayout(File directory)
Creates the user i18n structure or fill it if required.DefaultI18nInitializer
getDelegate()
Charset
getEncoding()
Get theCharset
encoding used for i18nProperties
file loading.I18nMessageFormatter
getMessageFormatter()
Get theI18nMessageFormatter
to use on each i18n message translation.File
getUserDirectory()
I18nBundle[]
resolvBundles()
Resolv the bundles.void
setEncoding(Charset encoding)
Setencoding
to use for i18nProperties
file loading.void
setMessageFormatter(I18nMessageFormatter messageFormatter)
SetmessageFormatter
to use on each i18n message translation.void
updateUserI18nLayout(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, setLoader
-
Methods inherited from class org.nuiton.i18n.init.I18nInitializer
isMissingKeyReturnNull, resolvBundles, setMissingKeyReturnNull
-
-
-
-
Field Detail
-
userDirectory
protected final File userDirectory
the user directory where to store the i18n resources.
-
delegate
protected final DefaultI18nInitializer delegate
the delegate initializer to obtain default i18n resources to put in user directory.
-
-
Constructor Detail
-
UserI18nInitializer
public UserI18nInitializer(File userDirectory, DefaultI18nInitializer delegate) throws NullPointerException
- Throws:
NullPointerException
-
UserI18nInitializer
public UserI18nInitializer(String i18nPath, File userDirectory, DefaultI18nInitializer delegate) throws NullPointerException
- Throws:
NullPointerException
-
-
Method Detail
-
getUserDirectory
public File getUserDirectory()
-
getDelegate
public DefaultI18nInitializer getDelegate()
-
getEncoding
public Charset getEncoding()
Description copied from class:I18nInitializer
Get theCharset
encoding used for i18nProperties
file loading.- Overrides:
getEncoding
in classI18nInitializer
- Returns:
- encoding to use
-
setEncoding
public void setEncoding(Charset encoding)
Description copied from class:I18nInitializer
Setencoding
to use for i18nProperties
file loading.- Overrides:
setEncoding
in classI18nInitializer
- Parameters:
encoding
- Charset encoding to use
-
getMessageFormatter
public I18nMessageFormatter getMessageFormatter()
Description copied from class:I18nInitializer
Get theI18nMessageFormatter
to use on each i18n message translation.- Overrides:
getMessageFormatter
in classI18nInitializer
- Returns:
- formatter to use
-
setMessageFormatter
public void setMessageFormatter(I18nMessageFormatter messageFormatter)
Description copied from class:I18nInitializer
SetmessageFormatter
to use on each i18n message translation.- Overrides:
setMessageFormatter
in classI18nInitializer
- Parameters:
messageFormatter
- I18nMessageFormatter to use
-
resolvBundles
public I18nBundle[] resolvBundles() throws Exception
Description copied from class:I18nInitializer
Resolv the bundles.- Overrides:
resolvBundles
in classDefaultI18nInitializer
- Returns:
- the bundles detected
- Throws:
Exception
- if any pb while getting bundles
-
createUserI18nLayout
protected void createUserI18nLayout(File directory) throws Exception
Creates 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:
Exception
- if any pb
-
updateUserI18nLayout
public void updateUserI18nLayout(File directory, I18nBundle[] bundles)
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
-
-