In some cases, the reliance on the browser's default locale may not be the most favorable option. In fact, the Web 2.0 style does not support this paradigm at all. Instead, most International websites offer visitors the option of selecting their preferred language and/or country so that their experience can be tailored to their particular tastes.
Controlling the Presentation Locales
Clicking on the Germany link brings up the German site, which conforms to the
(BTW, I will happily accept donations for that car.)
The Jaguar pages are built using Flash in order to provide very dynamic graphics and other multimedia content. Other sites, such as Expedia, !Yahoo Finance and Google Maps, provide highly interactive content using more "traditional" Web technologies.
Fetching Labels at Runtime
The drawback to this approach was that you could not change the values after the page had loaded. A more flexible way to fetch labels is to use Ajax with Dynamic HTML on the client side. Using this combination, you can update any part of the page without reloading everything.
The i18nSupportTestPage.jsp Source
The following page presents a welcome message to the visitor. It is contained in an
<H1> tag with an
ID of "
welcome". Rather than provide the text using server-side
Protoype.js script, although optional, is highly recommended for making Ajax calls easier. I simplified things even further by writing my own
AjaxCall() method in my
The i18n_support.js Script
All of the client-side i18n functionality resides in this script. It makes use of several Prototype features, such as
Element.observe(), and of course, the
Ajax.Request object. The
Event.observe() handler acts as a sink to the window
onload event in order to initialize other handlers and retrieve the initial value of the welcome message. My
AjaxCall() method adds some additional checks and error handling. Once the framework is in place, a label can be set with only one or two lines of code (see lines 4 and 5 below):