POSIX supports announcement mechanisms which allow settings for language, national conventions and character set to be defined both on a system-wide basis and for individual users or user groups.
You set your working environment by assigning the name of the required locale to a set of environment variables reserved for that purpose. Whenever an internationalized program is invoked, these environment variables are read and the information for the locale assigned to them is bound to the program’s runtime environment.
The environment variables which set the locale are:
Variable | affects: |
LANG | Entire locale |
LC_ALL | Entire locale |
LC_CTYPE | Character classes and case conversion (shifting) |
LC_COLLATE | Collating sequence |
LC_TIME | Date and time formats |
LC_MONETARY | Currency symbol and monetary value format |
LC_NUMERIC | Representation of the radix character, exponent character and digit grouping symbol |
LC_MESSAGES | Message texts and answers to yes/no questions |
The precedence among these variables is as defined in section “Precedence among environment variables”.
These variables can be defined in one of the following formats:
Format 1: | variable=locale_name |
Format 2: | variable=language[_territory][.codeset] |
locale-name
language[_territory][.codeset]
name of a directory under /usr/lib/locale. The length of this string should not exceed {NL_LANGMAX}.
The LC_CTYPE, LC_COLLATE, LC_TIME, LC_MONETARY, LC_NUMERIC and LC_MESSAGES variables also support an additional @modifier element specifying extra alternatives, for example a particular type of collating sequence:
LC_Variable=language_territory.codeset@modifier |
Example
In a German environment you can use @modifier to choose between the standard collating sequence (dictionary order) and the collating sequence preferred in the German telephone directory. The collation rules here differ in respect of uppercase and lowercase, umlauts and special characters. To select the phone book collating sequence you use the assignment:
LC_COLLATE=De_DE.88591@TE
If any of the variables LC_CTYPE, LC_COLLATE, LC_TIME, LC_MONETARY, LC_NUMERIC or LC_MESSAGES is undefined or is assigned the null string, its value defaults to the value of LANG.
If any of the variables LC_CTYPE, LC_COLLATE, LC_TIME, LC_MONETARY, LC_NUMERIC and LC_MESSAGES has an invalid value, or if the LANG variable is undefined or null, the system acts as if it were not internationalized; in other words, it collates according to the ASCII table, uses the American date format, English day and month names and so on. This is the default setting.