Pages

Monday, 10 October 2011

Xpages Internationalisation

Working in Europe for a multinational, providing a multi-lingual website is not an option, it is a must. So the option for internationalisation in Xpages is very welcome.
The standard xpages localisation option (in the application properties) creates a properties file per specified language per custom control/xpage. Works great, but it does create a lot of maintenance work if things needs changing afterwards or when you add a language.
There is another option available which is not as automated like the xpages localization, but in the long run will probably turn out to be more flexible when doing maintenance or adding an extra language.
Here is how it works:

- For every language create a properties file, a flat text file with the extension .properties and make them available to the application through the "file resources". For ease of use name these files something like english.properties, dutch.properties, etc. In the properties files add name-value pairs separated by the equals sign (=) for labels, buttons etc. in your applocation that you want translated. login_text=Login logout_text=Logout menu_text=Menu
....

- In a custom control that loads on every page in the application, e.g. an initialisation custom control, in the resources properties add a resource bundle, name it something like "lang" and compute the location to the desired language properties file, e.g. using the browser language setting or for testing as simple as below..return "/dutch.properties";

- Next go through all the xpages and custom controls and change the fixed text of labels, buttons, etc. by a value from the properties file set in the resources. lang.login_text

- After setting all the necessary entries in the properties file for the default language, create the file resources (copy) for the other languages. To spot not translated labels in the application, you can prefix them with the target language. login_text=[EN]Login logout_text=[EN]Logout menu_text=[EN]Menu
....

This process is best done at the end of the development phase of a project and work with a default language until than.

3 comments:

Hi Partick,We started the same here, with English as the communications language. But for customer facing websites we have been using multi lingual sites for several years now. And demand is growing for multi lingual intranet stuff as well.

I will build a small demo database that I will upload later this week.

About Me

IT architect/developer/project manager working with Lotus software for more than 15 years.
Available as independant consultant under Obento IT Consultancy and experienced with workflow, data exchange/synch, web development (incl. xpages), websphere commerce and more.