Welcome!

Weblogic Authors: Yeshim Deniz, Elizabeth White, Michael Meiner, Michael Bushong, Avi Rosenthal

Related Topics: Weblogic

Weblogic: Article

Cover Story: A Practical Solution to Internationalization of a J2EE Web App

Making Web Applications Multilingual

There was another twist to the requirements. There were different flavors of the booking engine, commonly referred to as booking engine sites. For example, there is a core booking site and a discounted booking site. Different sites will have different business rules. The business rules for a particular site can also vary across different POS countries. For example, the fare rules for a core booking site can be different on the US POS than are those on the UK POS. There were also special requirements in terms of the content displayed. It was expected that words with similar meanings for the same label in a particular language could be used across different sites. For example, Table 3 shows how the label for discounted fares was expected to be displayed on Core and Discount booking sites for the same US POS.

Another interesting requirement was to respect the colloquiality of the language based on the POS country. For example, if the user is in the Canadian POS and if the content is displayed in French, the colloquiality of French as spoken in Canada should be respected. However, if the user is in the French POS and if the content is displayed in French, then the colloquiality of the French as spoken in France should be preserved.

The final and the most critical requirement is that all the content that is localized will be managed through a content management application (CMA).

The aforementioned requirements clearly indicate that the content displayed on the Web application varies based on the POS country, user selected language, and the booking site. Based on this understanding, the following fallback rules to look up content from CMA were defined:

  • Consider "core" as default site, "English" (en) as default language, and "US" as default country
  • Find the content with exact match by using user selected site, language, and country
  • If the previous step fails, find the content by using user-selected site and language, but ignoring the country
  • If the previous step fails, find the content by using default site, user-selected language, and country
  • If the previous step fails, find the content by using default site and user-selected language, but ignoring the country
  • If the previous step fails, find the content by using user-selected site, default language, and default country
  • If the previous step fails, find the content by using default site, default language, and default country
  • If all of the above steps fail, then the content should be considered to be unavailable
The application that is presented in this article is a prototypical version of the actual application. The prototype helped us to focus on the subject and to provide clear explanations in this article.

The Foremost Thing to Do
The foremost thing to do in terms of internationalization is to identify the locale. The knowledge of a user's locale is the key to application internationalization. Java provides the Locale class in the java.util package to represent a user's locale. The Locale object uses ISO constants for countries and languages to determine a user's geographical, political, and cultural preferences. The Locale object also provides a placeholder for specifying a variant. Essentially, a variant helps in creating a custom locale by specifying additional information that can influence user preferences.

Typically, in the case of Web applications, a browser transmits a header "Accept-Language" in the HTTP request. This header contains more than one user-selected locale, and each locale is a combination of ISO language code and country code. Users normally have options on the browser to select a list of preferred language and country combinations. However, while selecting a locale to be used in the application, it is not reliable to depend totally on the value of this HTTP header because a user may or may not specify the right locale supported by the application. One way is to provide the user with the ability to select language and country preferences dynamically while interacting with the application.

In the application described in this article, it was not too difficult to determine what constitutes a user locale. As mentioned earlier, the content to be displayed is based on the user's choice of language, POS country, and booking site. Obviously POS country and user's choice of language can be easily represented in terms of ISO codes. The question was about the booking site. To address this, a meaningful but constant name was assigned to each booking site such as "core," "discount," etc., and this site name was considered as a variant in a Locale object.

Handling Localized Content
The important step in internationalization is the isolation of data elements that are candidates for localization. The following are some of the displayable data elements that can either be translated or formatted based on user's locale:

1.  Elements that can be translated:

  • Application messages
  • Labels and headers on the form fields
  • Online help content
  • Images and icons
  • Personal titles and greetings
2.  Elements that can be formatted:
  • Date and time
  • Numbers
  • Measurements (miles vs. km, etc.)
  • Currencies
  • Phone numbers
  • Mailing address
Java provides the ResourceBundle class in the java.util package to handle translatable data elements. A resource bundle in its simplest form is a collection of key-value pairs (a key is an index to a value that can be localized or translated). Property files are typically used to specify resource bundles. Custom resource bundles can also be created as Java classes by extending from the ResourceBundle class. In either case, the naming of the properties file or the custom class matters most. Resource bundle names have two parts: a base name and a suffix. The base name is an identifier for the resource bundle. The suffix is an identifier for the locale. For example, a properties resource bundle "AppResources" for the default locale will have a name "AppResources.properties." However, if the property values are translated to Chinese and French locales, then the new files will have names "AppResources_zh_CN.properties" and "AppResources_fr_FR.properties," respectively. If the application uses a custom locale with some variant such as the one used in the example application "fr_US_core," then the locale suffix should also contain the variant name, for example, "AppResources_fr_US_core.properties." One note of caution: when properties' resource bundles are being created, the right character set encoding should be used.

Resource bundles are loaded within the application by calling the "getBundle" static method on the java.util.ResourceBundle class and passing the base name of the bundle and the current locale. The loading of a resource bundle uses a locale fallback approach as shown in the flow diagram in Figure 5.

Creating property files with translated content is an approach typically used when the application is of medium size and the number of locales supported is small. However, in cases of large applications that need internationalization in many different locales, this approach may end up being a maintenance nightmare. For example, in the current application there are as many as 1200 possible custom locales (24 countries x 10 languages x 5 booking sites = 1200 custom locales), and there are thousands of data elements that need to be translated. Of course, most of the translated content in a particular language will be reused, but the idea of creating 1200 different property files with thousands of content entries is mind-boggling. However, the requirement to use CMA for localized content management and retrieval essentially eliminated any possibility of internationalization design based on locale-specific property files. It was inevitable to devise a strategy to pull the content without losing the internationalization features offered by Java and the Web frameworks such as Struts and JSTL.

Obviously, Locale and ResourceBundle are at the core of the internationalization features offered by Struts and JSTL. It was clear that a custom ResourceBundle instance should be created that can interact with the underlying CMA database to pull locale-specific content. The next question was whether there was a need to create a separate custom Resource bundle for each possible locale, particularly because of the way Resource bundles are looked up. If we took this approach, it meant that we had to create as many as 1200 unique Resource bundle implementations, one for each possible locale. This solution would not be any better than having hundreds of property files, so the conclusion was to create only one custom implementation and somehow incorporate it in the application.

More Stories By Murali Kashaboina

Murali Kashaboina leads Enterprise Architecture at United Airlines, Inc. He has 15+ years of enterprise software development experience utilizing a broad range of technologies, including JEE, CORBA, Tuxedo, and Web services. Murali previously published articles in WLDJ and SilverStream Developer Center. He has master’s degree in mechanical engineering from the University of Dayton, Ohio.

More Stories By Bin Liu

Bin Liu is a lead software engineer at United Airlines. Bin has more than seven years of experience developing distributed applications using J2EE technologies, WebLogic, Tuxedo, C++, and Web services. Bin has previously published articles in WLDJ.

Comments (2) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
Raj Kumar Kundu 06/04/08 10:52:33 PM EDT

This content is very useful for all those people who are thinking about internationalization of J2EE/ Web Based applications. It explains and points out the areas which should be rather can be considered for this activity. This can help people start thinking in right direction.
But this can be made extremely useful by providing some example files (Resource Bundle related AppResource files and the java files which are using those property files) or snaps of the java codes.

Henry 10/23/07 08:34:21 PM EDT

Is database-centric internationalization with JSF similar with this article?

@ThingsExpo Stories
With tough new regulations coming to Europe on data privacy in May 2018, Calligo will explain why in reality the effect is global and transforms how you consider critical data. EU GDPR fundamentally rewrites the rules for cloud, Big Data and IoT. In his session at 21st Cloud Expo, Adam Ryan, Vice President and General Manager EMEA at Calligo, examined the regulations and provided insight on how it affects technology, challenges the established rules and will usher in new levels of diligence arou...
Recently, WebRTC has a lot of eyes from market. The use cases of WebRTC are expanding - video chat, online education, online health care etc. Not only for human-to-human communication, but also IoT use cases such as machine to human use cases can be seen recently. One of the typical use-case is remote camera monitoring. With WebRTC, people can have interoperability and flexibility for deploying monitoring service. However, the benefit of WebRTC for IoT is not only its convenience and interopera...
The 22nd International Cloud Expo | 1st DXWorld Expo has announced that its Call for Papers is open. Cloud Expo | DXWorld Expo, to be held June 5-7, 2018, at the Javits Center in New York, NY, brings together Cloud Computing, Digital Transformation, Big Data, Internet of Things, DevOps, Machine Learning and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding busin...
SYS-CON Events announced today that Synametrics Technologies will exhibit at SYS-CON's 22nd International Cloud Expo®, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Synametrics Technologies is a privately held company based in Plainsboro, New Jersey that has been providing solutions for the developer community since 1997. Based on the success of its initial product offerings such as WinSQL, Xeams, SynaMan and Syncrify, Synametrics continues to create and hone inn...
Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
No hype cycles or predictions of a gazillion things here. IoT is here. You get it. You know your business and have great ideas for a business transformation strategy. What comes next? Time to make it happen. In his session at @ThingsExpo, Jay Mason, an Associate Partner of Analytics, IoT & Cybersecurity at M&S Consulting, presented a step-by-step plan to develop your technology implementation strategy. He also discussed the evaluation of communication standards and IoT messaging protocols, data...
Product connectivity goes hand and hand these days with increased use of personal data. New IoT devices are becoming more personalized than ever before. In his session at 22nd Cloud Expo | DXWorld Expo, Nicolas Fierro, CEO of MIMIR Blockchain Solutions, will discuss how in order to protect your data and privacy, IoT applications need to embrace Blockchain technology for a new level of product security never before seen - or needed.
In his session at 21st Cloud Expo, Raju Shreewastava, founder of Big Data Trunk, provided a fun and simple way to introduce Machine Leaning to anyone and everyone. He solved a machine learning problem and demonstrated an easy way to be able to do machine learning without even coding. Raju Shreewastava is the founder of Big Data Trunk (www.BigDataTrunk.com), a Big Data Training and consulting firm with offices in the United States. He previously led the data warehouse/business intelligence and B...
Cloud Expo | DXWorld Expo have announced the conference tracks for Cloud Expo 2018. Cloud Expo will be held June 5-7, 2018, at the Javits Center in New York City, and November 6-8, 2018, at the Santa Clara Convention Center, Santa Clara, CA. Digital Transformation (DX) is a major focus with the introduction of DX Expo within the program. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive ov...
A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, whic...
"Evatronix provides design services to companies that need to integrate the IoT technology in their products but they don't necessarily have the expertise, knowledge and design team to do so," explained Adam Morawiec, VP of Business Development at Evatronix, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, discussed how they built...
Digital Transformation (DX) is not a "one-size-fits all" strategy. Each organization needs to develop its own unique, long-term DX plan. It must do so by realizing that we now live in a data-driven age, and that technologies such as Cloud Computing, Big Data, the IoT, Cognitive Computing, and Blockchain are only tools. In her general session at 21st Cloud Expo, Rebecca Wanta explained how the strategy must focus on DX and include a commitment from top management to create great IT jobs, monitor ...
"Digital transformation - what we knew about it in the past has been redefined. Automation is going to play such a huge role in that because the culture, the technology, and the business operations are being shifted now," stated Brian Boeggeman, VP of Alliances & Partnerships at Ayehu, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, led attendees through the exciting evolution of the cloud. He looked at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering m...
SYS-CON Events announced today that Evatronix will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Evatronix SA offers comprehensive solutions in the design and implementation of electronic systems, in CAD / CAM deployment, and also is a designer and manufacturer of advanced 3D scanners for professional applications.
To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...
Nordstrom is transforming the way that they do business and the cloud is the key to enabling speed and hyper personalized customer experiences. In his session at 21st Cloud Expo, Ken Schow, VP of Engineering at Nordstrom, discussed some of the key learnings and common pitfalls of large enterprises moving to the cloud. This includes strategies around choosing a cloud provider(s), architecture, and lessons learned. In addition, he covered some of the best practices for structured team migration an...
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...