The goal of this sample application is to demonstrate how to
effectively localize ADF UIX
and JSP applications into multiple languages.
This sample application consists of 2 applications - one
named UIX_Browse_Emp.uix and the other JSP_Browse_Emp.jsp.
Each of these applications has been localized for Spanish
(Spain) language / locale.
To view the application in Spanish, simply set your browser to Spanish (Spain), and run the Index.JSP page, select the page of your choice and it should appear in Spanish.
Internet Explorer: Tools -> Internet Options -> General-> LanguagesNetscape/Mozilla: Edit -> Preferences -> Navigator -> Languages
Web applications are usually globally distributed, and
their users need to have interfaces in their own language and
numeric and date formats according to their local norms.
Translating applications is usually an expensive and difficult process. Fortunately,
Oracle ADF simplifies
the process of localizing your J2EE applications.
The sample ADF-UIX and ADF-JSP pages were built using JDeveloper
10g's drag-and-drop functionality, with Jakarta Struts as our
applications framework. Once built, the applications must
now be localized:
We built our application using Jakarta Struts, so we must
configure our application to specify the location of localizable
resources. Configuration of ResourceBundle location is set in the
Struts-Config.xml
file,
using the message-resources
tag.
The "view." prefix indicates that our sample application properties
file is located in the \View\src\view directory;
since "\View\src" is
the root directory.
Once defined, the resources can be referenced using the Jakarta
<bean> tag.

Once the basic application is built and configured, our next
task is to
identify and export all the strings needing localization to their
respective ResourceBundle containers in preparation for translation.
The Java platform provides robust built in localization
support, which means we don't have to do much coding in order for
our application to load at runtime the correct language resources to
match our user's browser language settings. The foundation of
Java's multilingual support is its ResourceBundle
architecture. ResourceBundles are containers of localizable
elements. organized in key-value pairs. Separate containers
(files) are created for each language our application supports.
Java ResourceBundles are subclasses into ListResourceBundle, which are
backed by Class (compiled Java ) files,
and PropertyResourceBundle,
which are backed by Properties
text files.
Model entity properties such as Column names, Hint Text, custom messages
Validation Errors and Messages.
Numeric and date format masks
All text strings, titles, etc.,
such as button
text, headers, titles, error message
Slightly slower performance than ListResourceBundle
Can contain only ASCII strings
(encoded as 8859-1)
JDeveloper 10g automatically generates a ListResourceBundle Java
file when strings are set in the Entity Object Editor. Most
strings are set in the "Control Hints" screen:
The resulting file EmployeesImplMsgBundle.java
is generated in the
\Model\src\model\common directory. Next, we copy
this file to EmployeesImplMsgBundle_es.java
in the same
directory, and we subclass the constructor (our changes in bold)::
public class
EmployeesImplMsgBundle_es
extends EmployeesImplMsgBundle
Next, the contents of our ListResourceBundle is translated
into Spanish. Once translated, the Java file is ready
to be compiled. Note that all non-ASCII characters within the
ListResourceBundle must be either be UNICODE escaped or the encoding
must be explicitly specified when compiling into byte-code. There
are two ways to approach this requirement:
No further coding is required in order for translations to be
displayed in either UIX or JSP pages.
Our PropertyResourceBundle, or
"properties files", contains the strings for our application's
user interface. This file contains key-value pairs, and we
can add new key-value pairs as we need them. Properties file
values do not require compilation, and the values are acquired by the
application at runtime.
As mentioned previously, the default
properties file is ApplicationsResources.properties,
and it resides in the \View\src\view directory.
So for our sample, we created
ApplicationsResources_es.properties
in same directory (\View\src\view) as base file
ApplicationsResources.properties
Strings within the JSP or UIX page are not
automatically exported to the properties file, so we must identify all
the strings in our application visually, then create "keys" for
them. The keys are unique names, and we choose names that
will help us identify where the text comes from. To help
identify the origin of the strings, they can be grouped
geographically using prefixes
tells
us the string is a title string
from the error page
or we can group them functionally,
which identifies the string as the name of
a button.
Once all the strings in the application
are represented in the properties file, we can copy the
contents of the English file to the Spanish file, and translate the
strings.
Once the properties files are translated, we must ensure that the strings are in a character set encoding that will be correctly interpreted by our application and correctly displayed by the client's browser. Although Java uses Unicode internally, properties files must contain characters that can be represented by the ISO 8859-1 character set. Any non-8859 character sets must be converted to escaped UTF-8 characters, or they will appear corrupt in the browser.
Once our strings are represented in our ResourceBundles, we
still have to modify our UIX and JSP pages to reference them. The
mechanism for referencing ResourceBundles differs for JSP and UIX pages.