Java Webapp localization through Gettext

18 January 2009

GNU HeadIntroduction

As you may know, native Java localization support is shaky at best. ResourceBundles, which are just straight Java classes, are compiled natively starting from “.properties” files; these are simple key-value files containing an abstract name for each string along with its associated translation.

Although this sounds great (“if support for l10n is already built in the language, why using an external tool?” – you may ask), some severe limitations exist. Treatment of singular-plural forms is bound to give you an headache — especially if the target language has more than two plural forms (like Polish, Romanian, Russian and many others), and .properties files make both difficult to have immediately understandable code to the developer, and enough informations for the translator.

On the top of it, tools for extracting strings from code, merging new ones and manage old translations aren’t even nearly as advanced as those of GNU Gettext.

Thus, in this article we will see how to prepare a little webapp for l10n support. We will see how to manage things both using JSP and a bit of “normal” Java code. We will firstly set up the webapp, then proceed marking strings, finally translating and compiling them into native ResourceBundles.

Read the rest of this entry »

Advertisements