Versions Compared

Key

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

Table of Contents

Overview

The framework supports internationalization (i18n) in the following places:

...

Resource Bundle Search Order

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

Tip
titlePackage hierarchy

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

Default action's class

If you configure action as follow

...

To display i18n text, use a call to getText in the property tag, or any other tag, such as the UI tags. (The getText technique is especially useful for labels of UI tags.)

Wiki Markup
{snippet:id=i18nExample|javadoc=true|lang=xml|url=org.apache.struts2.components.Property}

Note

The default implementation of TextProvider which is used in ActionSupport perform evaluation of value read from bundle base on the provided key, see Localizing Output for an example.

...

The text tag retrieves a message from the default resource bundle.

Wiki Markup
{snippet:id=i18nExample|javadoc=true|lang=xml|url=org.apache.struts2.components.Text}

Using the I18n tag

The i18n tag pushes an arbitrary resource bundle on to the value stack. Other tags within the scope of the i18n tag can display messages from that resource bundle.

Wiki Markup
{snippet:id=i18nExample|javadoc=true|lang=xml|url=org.apache.struts2.components.I18n}

Tip
i18n with SiteMesh
i18n with SiteMesh

Internationalizing SiteMesh decorators is possible, but there are quirks. See SiteMesh Plugin for more.

...

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

Wiki Markup
{snippet:id=globalresource|javadoc=true|url=com.opensymphony.xwork2.util.LocalizedTextUtil}

Formatting Dates and Numbers

...