Internationalizing Your Struts Applications
The internationalization support provided by the Struts framework focuses almost exclusively on the presentation of text and images for the application. Functionality such as accepting input from nontraditional languages is not covered within the Struts framework.
As you’ve already seen, depending on your Struts configuration settings, the framework can determine the preferred locale for a user and store it into the user’s session. Once the user’s locale has been determined, Struts can use this locale to look up text and other resources from the resource bundles. The resource bundles are essential components in the Struts framework.
The Struts Resource Bundle
As you saw in Chapter 4, each of your application modules can be configured with one or more resource bundles. The information within each bundle is available to actions, action forms, JSP pages, and custom tags alike.
Creating a Struts resource bundle
Resource
bundles that you create must follow the conventions of the
PropertyResourceBundle class from the Java core
library. That is, you need to create a text file for your resource
bundle that has a .properties extension and that
adheres to the guidelines discussed in the JavaDoc for the
java.util.Properties class. The most important of
these guidelines is that the format of the messages within this file
is:
key=value
Example 12-3 displays a properties file called StorefrontMessageResources.properties that can be loaded by the Struts ...
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