skip to main content
Programmer's documentation > Building Web Applications > JViews web applications globalization and multicultural support > Introducing globalization technologies used in JViews web applications
 
Introducing globalization technologies used in JViews web applications
This section provides general information about the globalization technologies used in JViews web applications.
Background
Software globalization includes two aspects:
*the internationalization mechanism
*multicultural support of an application.
JViews web applications use the standard globalization mechanism provided in the Java™ 2 Platform for both aspects, which includes Locale, ResourceBundle, and other Java classes. If you already understand these concepts and technologies, you can go through to the next sections directly. If you are new to globalization, this link is a good starting point: Sun Java Internationalization home page.
Starting with version 8.7, JViews supports a globalization mechanism for both JViews JavaServer™ Faces (JSF) and JavaScript™ applications. By following good programming practices and the guidelines set forth in this document, you can ensure that your web application is ready for translation without much additional effort.
The advanced globalization features described in Software globalization in JViews and Bidirectional text are also available in JViews web applications.
JViews JSF applications
It is assumed that you are familiar with JSF technology and JSF internationalization mechanisms as JViews JSF applications are based on this technology. If you are new to these concepts, refer to the detailed introduction for both concepts at The Java EE 5 Tutorial
Locale determination is usually the first step in the process of localizingJViews JSF web application. The locale determination process is based on requests sent by browsers. This means that the locale could be different for different requests. When the browser sends a new JSF request to the server side, the language options settings in the browser are transmitted as part of the HTTP Accept-Language header to the server. Then the server attempts to sequentially match the requested locales with supported ones in the JSF configuration file. (If no match is found, the default JVM locale is used.) For more details about the locale determination process, see Tips for multicultural support JViews web applications.
Since version 8.7, JViews uses the standard JSF globalization mechanisms to provide multicultural support for JSF web applications:
*Configure supported locales in the JSF configuration file faces-config.xml.
*Store localized data in resource bundles, which are represented as text files with the extension .properties. For more information about resource bundles, see Localization with ResourceBundles.
*Determine the right locale from the requested locales in the HTTP header.
*Load the resource bundle into the web page by using the JSF tag f:loadBundle.
*Retrieve localized data by using the standard JSF tags.
JViews JavaScript applications
In JViews JavaScript applications, the use of Unicode is strongly encouraged. Specifically, the UTF-8 encoding should be used for HTML, CSS and JavaScript files. When files are encoded in UTF-8, be certain to specify the encoding properly in the HTTP headers, HTML META, and SCRIPT tags.
The locale determination for JViews JavaScript applications is similar to the procedure for JViews JSF applications. The locale determination is based on requests, However, in JavaScript applications, the locale is determined by the Servlet class. When the browser sends a new HTTP request to the server side, the Servlet class analyzes the "Accept-Language" attribute, retrieves requested locales from the HTTP header, and then takes the first requested locale as the active locale. (If no "Accept-Language" attribute is found in the HTTP header because no language option has been set in the browser, then the default JVM locale is used). After the locale has been determined, it is stored in the current thread context and used directly for later tasks in the current thread. The stored locale is cleaned up when the request is finished.
Starting with version 8.7, JViews uses the Servlet class and JavaScript technologies to provide multicultural support for JavaScript web applications:
*Use the Servlet class to retrieve locale information from the attribute "Accept-Language" from the HTTP header when a new HTTP request comes in.
*Store localized data in the JavaScript class within curly brackets.
*Load the resource bundle into the web page by using JViews Asynchronous JavaScript And XML (Ajax) components.
*Reference localized data by using the complete JavaScript class path, such as ChildClassName.key.

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.