Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
6.0.0
Description
This proposed improvement derives from a discussion on the Struts Developer List, with the general idea introduced by Greg Huber.
Improvement: Introduce a new STRUTS_I18N_SEARCH_DEFAULTBUNDLES_FIRST control flag constant, and accompanying logic, with the default setting being false.
The new control flag will be used by AbstractLocalizedTextProvider descendants to identify alternative I18N resource bundle lookup logic that prioritizes key lookup in the default resource bundles (in cases where such a distinction makes sense).
The StrutsLocalizedTextProvider will use the flag to determine whether searches for resources will check the default bundles first (if the flag is true) or last (if the flag is false) for a match to a lookup key. The GlobalLocalizedTextProvider only searches default bundles, so the flag will have no effect on it.
The false setting corresponds to the standard lookup logic for the TextProviders in Struts 2, and will be the default, so that there will be no impact to existing applications. Applications that wish to enable the alternate lookup will do so by setting the flag to true in their Struts configuration.
With a true setting, if a key exists in a default resource bundle (such as the application's default resource bundle), it will supersede any such key in other bundles (such as ones at the package or class level). This will allow for a different resource bundle strategy when using the StrutsLocalizedTextProvider, and may be more efficient for applications that either only use a single global application resource bundle. or that use such a bundle for the vast majority of their I18N resource keys.