Internationalization Support with Tiles
Although the Struts framework provides certain I18N capabilities that can be used with Tiles, Tiles also provides the ability to select a particular tile based on the user’s locale. To support this feature in your application, you need to create a different Tiles definition file for each locale that you need to support. For example, if you need to support a set of definitions for the U.S. locale and a separate set for the German locale, you must create two separate definition files:
tiles-tutorial-defs_en.xml
tiles-tutorial-defs_de.xml
The suffix naming conventions follow the ones set by the
java.util.ResourceBundle, which is also used by
the resource bundles for Struts. When a request for a definition is
made, the correct definition is determined by the included locale.
Tip
As with regular Java resource bundles, you should always provide a base definition that is used when no locale is provided or when an unsupported locale is used. No language or country suffix is appended to the name of the Tiles base definition file.
Once you have created the locale-specific definition files and placed
them in the WEB-INF directory,
the only other necessary step is to ensure that a
Locale is stored in the user’s
HttpSession. The Tiles framework depends on the
same Locale instance that Struts uses to determine
which definition file to use. You will need to ensure that the Struts
framework is storing the user’s
Locale in the session. This is accomplished ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access