| [ Team LiB ] |
|
Chapter 14. InternationalizationTaking the term World Wide Web literally means that your web site needs to respect the local languages and customs of all visitors, no matter where they come from. More and more, large web sites provide content in several different languages. Just look at sites like Yahoo!, which provide directory services in the local language of more than 20 countries in Europe, Asia Pacific, and North and South America. Other good examples are CNN, with local news for 3 continents in 7 different languages, and Vitaminic (http://www.vitaminic.com/), a site with MP3 music and artist information customized for different countries. If the site contains only static content, it's fairly easy to support multiple languages: just make a static version of the site for each language. But this approach is not practical for a site with dynamic content. If you develop a separate site for each language, you will have to duplicate the code that generates the dynamic content as well, leading to maintenance problems when errors are discovered or when it's time to add new features. Luckily, Java and JSP provide a number of tools to make it easier to develop one version of a site that can handle multiple languages. The process of developing an application that caters to the needs of users from different parts of the world includes two phases: internationalization and localization. Internationalization means preparing the application by identifying everything that will be different for different geographical regions and providing means to use different versions of all these items instead of hardcoded values. Examples of this are labels and messages, online help texts, graphics, format of dates, times and numbers, currencies, measurements, and sometimes even the page layouts and colors. Instead of spelling out the word internationalization, the abbreviation I18N is often used. It stands for "an I followed by 18 characters and an N." When an application has been internationalized, it can also be localized for different regions. This means providing the application messages, help texts, graphics, and so forth, as well as rules for formatting dates/times and numbers, for one or more regions. Localization is sometimes abbreviated L10N, following the same logic as the I18N abbreviation. Support for new regions can be added without changing the application itself, simply by installing new localized resources. In this chapter, we first look at the basic Java classes used for internationalization. If you're not a programmer, you can skim through this section without worrying about the details. (However, you should understand the terminology, and knowing a bit about the inner workings of these classes also makes it easier to understand the rest of the chapter.) We then develop a web application in which visitors can answer a poll question and see statistics about how other visitors have answered, using a set of JSTL actions that hide the Java classes and make internationalization a lot easier. The poll site is localized for three languages. The initial language selection is based on the user's browser configuration, but users can also explicitly select one of the supported languages. The last part of this chapter discusses the issues related to interpreting localized input and the special considerations needed for dealing with languages containing other characters than those used in Western European languages. |
| [ Team LiB ] |
|