Chapter 9. Localization

Table of Contents

Localization of HTML Templates
Localization of Assets
Other Options for Localization

One of the most powerful and useful features of the Tapestry framework is the way in which it assists with localization of a web application. This is normally an ugly area in web applications, with tremendous amounts of ad-hoc coding necessary.

Because Tapestry does such a strong job of seperating the presentation of a component (its HTML template) from its control logic (its specification and Java class) it becomes easy for it to perform localization automatically. It's as simple as providing additional localized HTML templates for the component, and letting the framework select the proper one.

However, the static text of an application, provided by the HTML templates, is not all.

Applications also have assets (images, stylesheets and the like) that must also be localized: that fancy button labeled "Search" is fine for your English clients, but your French clients will require a similar button labeled "Recherche".

Again, the framework assists, because it can look for localized versions of the assets as it runs.

The locale application demostrates this. It is a very simply application that demonstrates changing the locale of a running application [7]

A demonstration of localization is built into the Workbench, under the L10N [8] tab. The page allows the user to select a new language for the application:

Figure 9.1. L10N Page (English)

L10N Page (English)

Selecting "German" from the list and clicking the "Change" button brings you to a new page that acknowledges your selection:

Figure 9.2. Locale Changed (German)

Locale Changed (German)

Clicking the button (it's labeled "Return" in German) returns you to the L10N page to select a new language:

Figure 9.3. L10N Page (German)

L10N Page (German)

The neat thing here is that the L10N page has been localized into German as well; it shows equivalent German text, the options in the popup list are in German, and the "Change" button has been replaced with a German equivalent.



[7] All the translations were performed using Babelfish, and are probably quite laughable to someone who actually speaks the alternate languages.

[8] The "10" refers to the number of letters between 'l' and 'n' in the word 'localization'