[
https://issues.apache.org/jira/browse/SLING-2047?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Felix Meschberger resolved SLING-2047.
--------------------------------------
Resolution: Fixed
Assignee: Felix Meschberger
Fixed in Rev. 1088913 (testcases) and 1088914 (implementation).
The JcrResourceBundle.handleGetObject(String key) method now only returns the
resource if it is known to the resource bundle and null otherwise. In this case
the ResourceBundle.getObject(String key) method will call the parent resource
bundle and so forth.
To still ensure we always have a mapping we have a special RootResourceBundle
which always returns the key as the (String) value as a last ressort.
> Properly provide locale inheritance support
> -------------------------------------------
>
> Key: SLING-2047
> URL: https://issues.apache.org/jira/browse/SLING-2047
> Project: Sling
> Issue Type: Improvement
> Components: Extensions
> Affects Versions: I18n 2.0.4
> Reporter: Felix Meschberger
> Assignee: Felix Meschberger
> Fix For: I18n 2.0.6
>
>
> The ResourceBundle class is intended to be used with inheritance of resources
> from parent resource bundles. Thus the ResourceBundle.getObject(String) is
> implemented along these lines:
> Object obj = handleGetObject(key);
> if (obj == null) {
> if (parent != null) {
> obj = parent.getObject(key);
> }
> if (obj == null) {
> throw new MissingResourceException(...)
> }
> }
> return obj;
> The JcrResourceBundle.handleObject(String key) method is implemented like
> this:
> Object value = // get from the repository resources
> return (value == null) ? key : value;
> That is the key is returned if there is no value. This, though, breaks the
> inheritance chain intended by the ResourceBundle.getObject(String) method. We
> should fix this along these lines:
> * The JcrResourceBundleProvider provides a root ResourceBundle
> implementation as follows:
> - handleObject(String key) always returns the key
> - getLocale() returns an empty Locale
> - getKeys() always returns an empty enumeration
> * The root ResourceBundle is used as the parent for all JcrResourceBundle
> instances which have no Locale induced parent
> * JcrResourceBundle.handleGetObject(String key) only returns the value for
> the given locale
> This way we can keep the guarantee that getObject(String key) method of a
> ResourceBundle provided by the JcrResourceBundleProvider never throws a
> MissingResourceException.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira