Java Reference
In-Depth Information
and returns a suitable object for a particular locale. For example, by
invoking the class's getInstance methods, you can get an appropriate
java.util.Calendar object that works with the user's preferred dates and
times. The returned Calendar object will understand how to translate sys-
tem time into dates using the customs of the default locale. If the user
were Mexican, an object that was a Calendar adapted to Mexican cus-
toms could be returned. A Chinese user might get an object of a differ-
ent subclass that worked under the Chinese calendar customs.
If your program displays information to the user, you will likely want to
localize the output: Saying "That's not right" to someone who doesn't
understand English is probably pointless, so you would like to translate
(localize) the message for speakers in other locales. The resource
bundle mechanisms help you make this possible by mapping string keys
to arbitrary resources. You use the values returned by a resource bundle
to make your program speak in other tonguesinstead of writing the liter-
al message strings in your code, you look up the strings from a resource
bundle by string keys. When the program is moved to another locale,
someone can translate the messages in the resource bundle and your
program will work for that new locale without your changing a line of
code.
The classes described in this chapter come mostly from the package
java.util . There are occasional brief discussions of classes in the text
internationalization and localization package java.text , with an overview
of some of its capabilities in Section 24.6 on page 708 , but a full discus-
sion on this subject is outside the scope of this topic.
 
Search WWH ::




Custom Search