Skip to main content

Luxor localization

Posted by dcengija on March 23, 2004 at 6:32 AM PST

Luxor is a useful tool: it really increases your productivity. Usage is simple: define your user interface in an XML file, add some Java meat around it and you have it running. Everything's nice and clean as long as you have only one human language to support.

Part of an XML user interface definition

<vbox >
<spacer style="height:10px;" />
<button command="test_users"  label="Test Users"
<spacer style="height:5px;" />
<button command="test_groups" label="Test Groups" 
<spacer style="height:5px;" />
<button command="test_modules" id="button7"
            label="Test ACL" enabled="false" 
<button command="test_parentgroups" id="button8"
            label="Test Application PARENT GROUPS" enabled="false" 
<button command="test_calendar" id="button9"
            label="Test Calendar" enabled="false"  style="height:35px;"/>
<choice list="lista" />

As soon as you introduce another language, you have problems. As shown in the XML snippet above, Luxor uses label, value and other attributes to assing the text to be displayed in the GUI. Unfortunatelly, those text values are hard coded and your only option is to provide different set of XML definitions for each human language you want to support. Please note that noone said 'different XML files', but 'different XML definitions', and that's the place where XSLT jumps in.

The approach we took was to translate XML definitions on the fly, using a simple XSLT stylesheet. To achieve that, we needed to do four things: 1. Edit XML definitions and add a custom attribute to those elements you want to translate, 2. Create an XSLT stylesheet which will transform XML definitions, 3. Create your translation file in the language of your choice and 4. Edit Luxor's code and glue it all together.

Changing XML definitions

We decided to add another attribute, tranid to each element we want to translate. So, for example, first element from the XML snippet shown above will look like