Globalization Support for JViews Web Applications
JViews 8.7 has improved globalization support for messages and resources, including a new feature that greatly simplifies the process of adapting your Web applications to handle different languages and cultures. Web applications deployed in multi-cultural environments are required to answer to client requests in their specific language, respecting their local context (locale) for date and numeric formats, system of measurement, etc.
The HTTP specification addresses this requirement by defining an Accept-Language request header to identify the language accepted by the client; it is sent by the browser when requesting a document to the server:
GET /index.html HTTP/1.1
User-Agent: Mozilla/5.0 Gecko/20100315 Firefox/3.5.9
You can manually change the language settings in most mainstream browsers, see more details here
Starting in JViews 8.7, tracking of the Accept-Language header allows JViews based Web applications to support multiple locales and respond to client requests in accordance with their preferred languages. This post briefly explains how you can make use of this new client-dependent locale support in your Web applications.
Globalization of a JViews JavaServer Faces Web application
In JSF Web applications, the globalization is done through the regular JavaServer Faces inte
Then the corresponding property files are created to hold the locale-specific data in key/value format:
Default property file: mess
Retrieving locale-specific messages based on the browser locale:
Retrieving locale-specific messages based on the server locale:
The server and browser locale are not necessarily the same in multi-cultural applications; the server locale represents the language preferences for the application administrator while the browser locale represents the end user preferences.
The convenient JSF loadBundle tag is used to retrieve locale-specific messages on the client side:
<f:loadBundle baseName=”messages” var=”msg” />
Default message file: script-messages.js
Chinese message file: scri
panMapToNorth:"pan the map to the north",
panMapToSouth:"pan the map to the south",
var topbutton = new IlvButton();
As you can see, JViews 8.7 makes it easy to have multiple locale support in your Web application, even if you need to adapt your existing project; all you have to do is keep your locale-specific data well organized and the rest will be simple.
You are welcome to look at the JViews Web applications globalization and localization chapter in the Programmer’s documentation for more detailed information, best practices for locale-aware Web applications and also hints on how to adapt your existing projects to support multiple languages. You should also check the Web samples as they have been updated to illustrate how this new feature works.