Internationalization? Localization? Arg! |
As you saw on the previous page, even a small applet such as the WordMatch applet poses many problems to the global programmer. Fortunately, JDK 1.1 contains many features to help you combate these problems and create global programs with little effort.The following list describes the features in the JDK 1.1 that help you solve the problems listed on the previous page.
Solution to Problem One: The
Locale
ClassTo identify the user's language and country, JDK 1.1 provides the newLocale
class.In Java, locales are not a global attribute of the whole program. Rather, each locale-sensitive object maintains its own locale-specific information. Locale-sensitive operations require a Locale object as an argument. This design is quite flexible and, in addition to other nifty things, allows a program to use and display multiple Locales at the same time. What Are Locales and How Do I Use Them? later in this lesson covers the Locale class and its use.
In addition, the JDK itself supports many of the more common locales, such as France, Germany, the various regions of Canada and so on.
Solution to Problem Two:
ResourceBundle
sJava provides several classes that help you bundle resources, such as strings and other language-dependent objects, within your global programs. Managing Locale-Sensitive Data covers managing strings and other objects in a language-independent manner.Solution to Problem Three: The
Format
ClassesAs with the WordMatch program, formatting messages is another locale-sensitive feature of many programs. Other data types, such as numbers and dates, must also be formatted in a locale-sensitive way. For example, what date does the following represent: 12/1/97? Your answer depends on where you live. In some locales, the date is December 1, 1997, in others, January 12, 1997. A significant difference if you're talking about deadlines or a child's birthday.The JDK 1.1 provides several classes that allow a program to display dates, numbers, and messages in a locale-sensitive way. These features of the JDK are covered thorougly in How to Format Numbers, Dates and Times, and Messages.
Solution to Problem Four: The
Collation
ClassTheCollation
class is new for 1.1 and provides the ability to compare strings in a language-sensitive manner. This capability allows programs to sort text and perform language-sensitive searching.The Collation and Text Boundaries lesson is under construction. Currently, it contains two demo programs by Taligent that show off the JDK's collation and text boundary features.
Solution to Problem Five: Unicode
As always, you write Java programs in Unicode--a 16-bit international character encoding standard. Unicode has the capacity to represent over 65,000 characters--ample enough to include characters for most of today's spoken languages.The above list describes the JDK 1.1 features that solve the most common problems programmers will encounter when writing a global program. In addition to these, programmers writing longer, more complex programs may have even more issues to consider: Character handling, text boundaries, other character encodings, and so on. The JDK 1.1 includes other enhancements that authors of larger more complex programs may need to help them write global programs:However, previous releases of the JDK could only display characters in the Latin-1 subset of Unicode. Now, with JDK 1.1, your Java programs can display any Unicode character that can be rendered with a host font.
[PENDING: link to lesson covering Unicode and other character-encoding issues]
- Calendar and Time Zone Support
The JDK 1.1 release provides several new classes that provide for the language-sensitive management of dates and times. This includes support for time zones.
The Representing Dates and Times page is under construction. When completed, it will cover how to store dates and times in a locale-sensitive way.
- Character Encoding
Java uses Unicode as its native character encoding; however, many Java programs still need to handle text using other encodings. The JDK 1.1 provides a set of classes that convert many standard character encodings to and from Unicode.
Additionally, the JDK 1.1 also provides the
TextBoundary
class for finding various boundaries in text such as word boundaries, line boundaries, and sentence boundaries. This enable intelligent text selection and line-wrapping.[PENDING: link to lesson]
- Character-based I/O Streams
The JDK 1.1 provides new stream classes that are based on characters rather than bytes. These new character-based I/O streams are covered in the Input and Output Streams.
- Character Classification
The
Character
class which allows you to wrapchar
data and determine certain characteristics of the character such as whether it's lower case and so on.[PENDING: link to lesson]
- AWT Enhancements
AWT
Component
s now have two attributes, name and Locale, to aid in the internationalization of a program's graphical user interface.[PENDING: link to lesson]
- Globalized Exceptions
An Exception can now get its message from a ResourceBundle making it possible for exception messages to be localized at the presentation site.
[PENDING: link to lesson]
Internationalization? Localization? Arg! |