ResourceBundleL10nResourceFactory
This library extends on the standard ResourceBundle api to provide a configurable
resource lookup directory path and the ability to look up and load locale dependent image resources.
It contains a sji18n.L10nResourceFactory implementation using and
extending ResourceBundle lookup by providing a custom ImageResourceBundle
to load image resources and a custom ResourceBundleLookupControl .
The custom control is able to find image resources or property resources in configurable resource
directories.
If no property resources are found there the standard behavior of ResourceBundle lookup is
used to locate resources on the classpath.
ImageResourceBundle and ResourceBundleLookupControl have no dependency on any
class of the
sji18n api and can be used without the sji18n api being available.
|
Features
- sji18n.L10nResourceFactory service provider.
- Supports loading images from directories containing image files.
These directories are considered image resources.
- Provides a
ResourceBundle.Control implementation able to load image resources and
properties resources from lookup directories. It can load any standard resource bundle available
on the classpath.
|
Sample
The following figure illustrates how an image resource directory is organized and how an ImageResourceBundle loads images and properties.
|
With the 'resources' directory in a ResourceBundleLookupControl 's lookup path,
ResourceBundle.getBundle("i18n", new Locale("en", "US"), control)
will create an ImageResourceBundle containing keys "a", "b" and "c" and any keys (and corresponding values) found in file 'i18n_en.properties'.
The values for keys "a", "b" and "c" will be the corresponding images loaded from the files in the 'i18n_en' directory.
|
|
Implementation notes
Defines and uses the following system properties to configure default behavior:
sji18n.resourcebundle.image.file.extensions defined in ImageResourceBundle
specifies the file extensions marking files that should be loaded as images.
This is used when loading an ImageResourceBundle . Valid values are comma separated
file extensions (no spaces, no points). Default value if not set is "jpeg,jpg,png".
sji18n.resourcebundle.lookup.path to set the default resource lookup directories. When
not set, the application's working directory is assumed to be the default lookup directory.
sji18n.resourcebundle.path.separator to define the path separator expression used in
the above property value. If not set, File.pathSeparator is assumed to be the path
separator used.
sji18n.resourcebundle.hide.missing.resource.exceptions (since 1.1) to effectively hide all
MissingResourceExceptions. If set, when a value for a key is not found,
the key itself will be returned. Use this option with caution because this may
trigger ClassCastExceptions or other failures when another type of value object is expected.
|