|Writing Global Programs|
When you first invoke AroundTheWorld you see a window that looks like this:
You use the flag symbols at the top of the window to choose a new locale. The currently selected locale is indicated by a thick border around the flag. When you select a new locale, the window changes to display useful tidbits of information about that locale: the name of the locale, today's date, the per capita GDP, the population, the literacy rate, and a brief paragraph describing the region. (These tidbits were retrieved from the CIA's 1994 World Fact book on the Internet).
In addition to the facts displayed about each locale, AroundTheWorld lets you to play the words book, car, dog, and apple in the language that is dominant in the selected locale. Note: this works only if you are running AroundTheWorld as an applet. Sounds aren't available to stand-alone programs. (Our thanks to Patrick Chan for writing the WordMatch applet from which we swiped these images and sounds.)
AroundTheWorld is a global program--it's completely internationalized and it's been localized for three locales: the United States, France, and French Canada.
The ClassesThe IntlWindow class implements the main window of the program. This window is divided into two functional areas. The first area, shown below, is the control area. The objects in the control area (panels, canvases, and images) are shared by all locales.
The rest of the window comprises the second area--the display area--of the program. This area is laid out by a CardLayout object which manages one LinguaPanel per supported locale. Each locale, then, has a different LinguaPanel and GUI elements for displaying its information. When you choose a new locale, the CardLayout object shows the appropriate LinguaPanel. (See How to Use CardLayout for information about CardLayout and another example that uses it.)
The data that you see and hear in the display area are the bulk of the locale-sensitive data of the program. All locale-sensitive data are contained in ResourceBundles.
AroundTheWorld defines four different ResourceBundle ancestors:
- LabelsBundle--A ListResourceBundle that contains the text labels.
- NumbersBundle--A ListResourceBundle that contains the numeric data.
- MediaBundle (and its subclass FlagNSoundsBundle)--Another ListResourceBundle that contains the audio clips and flag images.
- ParagraphBundle--A PropertiesResourceBundle that contains the paragraph description of the locale.
Each supported locale has its own version of each of the ResourceBundles listed above.
AroundTheWorld demonstrates several of the internationalization features of the JDK 1.1, including locales, resource bundles, calendar (and time zone) support, and formatting of date, currency, percent, and number data.
Future Improvements to AroundTheWorld
- get the program to run as an applet
- the get it to play the sounds
- get "real" translations and data for the non-US locales
- have a list to sort (collation)
- display the current time (this depends on TimeZones getting fixed in the jdk)
- support a non-western language such as Japanese
- do text and word boundaries in the text area
- format a message (instead of "" + "" style messages)
- character set conversion
- name attribute, locale attribute (actually we already do locale attribute by getting the locale from the window)
|Writing Global Programs|