Chapter 4: Locale and Cultural Awareness

Chapter 4: Locale and Cultural Awareness

Glossary


  • Gregorian calendar: A solar-based dating system used as the default calendar of countries in the Western hemisphere and also used widely in other parts of the world.

Implementing universally encoded applications and conforming to Unicode standards, as discussed in the previous chapter, is a major step toward creating a world-ready application. After all, it does not matter how well your application is designed to accommodate the localization process or to handle Input Method Editors (IMEs) if it cannot display the proper character in a multilingual context. Universal encoding is only one component of well-globalized software. There are still other considerations and challenges, including locale awareness.

A locale-aware program is software that observes language rules and cultural conventions that the user has selected. Representing formatted data such as the date, time, and currency symbols becomes a sensitive issue, since their final representation can have different meanings and interpretations from one language and culture to another. Take a simple example of a short date in the Gregorian calendar: 04/01/02. What date is this really?

  • April 1, 2002, if you are in the United States and the default standard is mm/dd/yy (month/day/year)
  • January 4, 2002, if you are in the United Kingdom and the default standard is dd/mm/yy (day/month/year)
  • January 2, 2004, if you are in Hungary and the default standard is yy/mm/dd (year/month/day)

(For information on how to use short-date or long-date formatting-such as April 1, 2002-see "Date and Calendar Formatting" later in this chapter.)

And yet this example only involves the Gregorian calendar, without getting into the complexity of alternative calendars such as the Hijri (Islamic lunar) or Hebrew lunar calendars. Can you imagine the confusion for a user who is look-ing, for example, at the last time his or her system has been backed up, and the possible consequences of such misinterpretations?

Microsoft Windows provides generic support for linguistic and cultural conventions through Microsoft Win32 National Language Support (NLS) application programming interfaces (APIs), as well as the Microsoft .NET Framework, which carries information on date, time, calendar, number, and currency formats. These APIs also provide sorting and character-type information for all the locales supported by the operating system. Microsoft Windows XP and Microsoft Windows .NET Server Family have integrated support for over 135 different locales, and this number will continue to grow in future releases of Windows. (See the full list at http://www.microsoft.com/globaldev/nlsweb/ and in the Samples subdirectory on the companion CD.)

A great deal of linguistic research went into creating the collection of locale information in the operating system and into the algorithms and tables used by the NLS API. You'll save yourself a lot of trips to the library, as well as the drudgery of maintaining locale information and code, by taking advantage of what the system offers. Generic code based on the NLS API will work for any locale the system supports.

It's important to mention at this early stage that because world-ready applications can never assume in which language they will display information to the user, all internal data should be stored in some predefined locale-neutral (with-out reference to language or geographic area) binary or string format. This way the data can be shared, without need for conversion, among users running your applications with different locale settings. For example, Microsoft Excel stores dates as sequential numbers known as "serial values." It also stores times as decimal fractions because time is considered a portion of a day. Thus Excel not only allows you to perform mathematical operations with dates and time, but also allows you to display the date and time in any locale format the user currently has set.

This chapter demonstrates how you can take advantage of locale-aware and culture-aware techniques to write code for Win32, Web, .NET, and console environments.

It will show you how to retrieve cultural information, and how to format dates, calendars, time, and currency. In addition, the chapter will establish how to handle sorting and stringcomparison, number formatting, as well as various international conventions involving addresses, paper size, telephone numbers, and units of measurement. By adhering to these techniques, you can avert potential misrepresentation, misinterpretation, and confusion.



Microsoft Corporation - Developing International Software
Developing International Software
ISBN: 0735615837
EAN: 2147483647
Year: 2003
Pages: 198

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net