
|
JSR 238, Internationalization API, provides the Java The API basically consists of two parts. The first part handles formatting of date, time, currency, strings and more via method calls. The second part makes use of binary resource files to provide localized data. The Formatter class and the StringComparator class can be used to format and compare locale-specific data. Supported locales can be queried by any of the classes. String[] locales = Formatter.getSupportedLocales(); StringComparator comparator = new StringComparator("en-US"); In order to use this class, you must first use some external tools to generate binary data that can be understood by the ResourceManager. One way to do this is to use the Nokia ResourceMaker. The first thing you must do is to create an XML file containing all your strings and locales. Such an XML file is provided in the example that can be downloaded. This text does not go into detail on how to generate these binary files, as it can be done in many ways and with existing documentation. More information on how to do this here>> Based on the XML file that the tool uses as input, a Java source file is generated for you to use in your program. This Java source file contains named indexes that are needed to extract the localized data from the binary files. It looks something like this: public static final int WELCOME = 1; When you use the tool to generate the Java file and the binary files, you give it a base name used to identify this resource set. This name is used in your code to retrieve the ResourceManager instance. ResourceManager manager = ResourceManager.getInstance("basename", "locale");
|
Copyright © 2001 - 2009 Sony Ericsson Mobile Communications AB. All Rights Reserved.