Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Resource Bundle Search Order

Resource bundles are searched in the following order:

  1. ActionClass.properties
  2. Interface.properties (every interface and sub-interface)
  3. BaseClass.properties (all the way to Object.properties)
  4. ModelDriven's model (if implements ModelDriven), for the model object repeat from 1
  5. package.properties (of the directory where class is located and every parent directory all the way to the root directory)
  6. search up the i18n message key hierarchy itself
  7. global resource properties

This is how it is implemented in a default implementation of the LocalizedTextProvider interface. You can provide your own implementation using TextProvider and TextProviderFactory interfaces.

Wiki Markup
{snippet:id=searchorder|javadoc=true|url=com.opensymphony.xwork2.util/LocalizedTextUtil.java}
For more, see the LocalizedTextUtil class.

{snippet:id=packagenote|javadoc=true|url=com.opensymphony.xwork2.util/LocalizedTextUtil.java}

Tip
titlePackage hierarchy

To clarify #5, while traversing the package hierarchy, Struts 2 will look for a file package.properties:

com/
acme/
package.properties
actions/
package.properties
FooAction.java
FooAction.properties

If FooAction.properties does not exist, com/acme/action/package.properties will be searched for, if not found com/acme/package.properties, if not found com/package.properties, etc.

Wiki Markup

Default action's class

If you configure action as follow

...

Global Resources (struts.custom.i18n.resources) in struts.properties

Wiki Markup{snippet:id=globalresource|javadoc=true|url=com.opensymphony.xwork2.util.LocalizedTextUtil}A global resource bundle could be specified programmatically, as well as the locale.

Formatting Dates and Numbers

...