Home | Download | Showcase | Overview | Widgets | API | |
Overview Calculator Hierarchy Properties Events XML Internationalization |
Internationalization A simple solution to internationalize texts (and other properties) depending on the current or selected locale is the separation of property values into locale-specific objects. You can specify a resource bundle containing translated values using the following method: public void setResourceBundle(ResourceBundle resourcebundle) The following example creates two buttons (yes and no), in the XML file the translated attribute values are marked with the i18n. prefix: <panel>
Note: you can internationalize not only string values, e.g. you can set the state field visible only for the _en_US locales. Note: the ResourceBundle class loads resources using the 8859-1 charset, thus for other characters you (or a properties editor) have to use the\u???? format including its hexadecimal code.
The mypackage/myresources_de.properties file includes German texts: yes=Ja
and mypackage/myresources.properties the English words: yes=Yes
The Java source contains the setResourceBundle(ResourceBundle.getBundle("mypackage.myresources")); Presumably the application's locale is defined at startup, or only the first (e.g. login) screen have to be reloaded. Changing locale runtime seems to be complicated, you have to update all the localizable data (numbers, dates, messages, or cell values coming from internationalized database views, etc.). |
Copyright © 2002-2006 Robert Bajzat - All rights reserved. |