Different countries and cultures have varying conventions for how to communicate. These conventions range from very simple ones, such as the format for representing dates and times, to very complex ones, such as the language spoken.
Internationalization of software means programming it to be able to adapt to the user's favorite conventions. In ISO C, internationalization works by means of locales. Each locale specifies a collection of conventions, one convention for each purpose. The user chooses a set of conventions by specifying a locale (via environment variables).
All programs inherit the chosen locale as part of their environment. Provided the programs are written to obey the choice of locale, they will follow the conventions preferred by the user.
Each locale specifies conventions for several purposes, including the following:
What multibyte character sequences are valid, and how they are interpreted (Chapter 7).
Classification of which characters in the local character set are considered alphabetic, and upper- and lower-case conversion conventions (Chapter 5).
The collating sequence for the local language and character set (the section called “Collation Functions”).
Formatting of numbers and currency amounts (the section called “Generic Numeric Formatting Parameters”).
Formatting of dates and times (the section called “Formatting Calendar Time”).
What language to use for output, including error messages (Chapter 9).
What language to use for user answers to yes-or-no questions (the section called “Yes-or-No Questions”).
What language to use for more complex user input. (The C library doesn't yet help you implement this.)
Some aspects of adapting to the specified locale are handled automatically by the library subroutines. For example, all your program needs to do in order to use the collating sequence of the chosen locale is to use strcoll or strxfrm to compare strings.
Other aspects of locales are beyond the comprehension of the library. For example, the library can't automatically translate your program's output messages into other languages. The only way you can support output in the user's favorite language is to program this more or less by hand. The C library provides functions to handle translations for multiple languages easily.
This chapter discusses the mechanism by which you can modify the current locale. The effects of the current locale on specific library functions are discussed in more detail in the descriptions of those functions.