locale(5P) —
NAME
locale − define and set international environment
DESCRIPTION
A locale is made up from one or more categories. Each category is identified by its name and controls specific aspects of the behavior of components of the system. Category names correspond to the following environment variable names:
LC_ALL Overrides the settings of all of the following environment variables.
LC_COLLATE Affects the behavior of the string collation functions.
LC_CTYPE Affects the behavior of the character handling functions.
LC_MESSAGES
Affects the interpretation of the strings associated with affirmative (y) and negative (n) responses.
LC_MONETARY
Affects the monetary formatting information returned by the localeconv(3P) function.
LC_NUMERIC Affects the decimal-delimiter character for the formatted input/output functions and the string conversion functions, as well as the non-monetary formatting information returned by the localeconv function.
LC_TIME Affects the behavior of the strftime function (see ctime(3P)).
LANG Provides a “fallback” value to be used if one of the above (except LC_ALL) is not set or is set to the empty string.
Programs compiled and linked with the −Xp option can use the setlocale function to modify the environment. When the program starts, the environment is set to the C locale, which corresponds to the traditional UNIX System environment. Programs can modify this environment by using the setlocale(3P) function.
If so directed by the program, the values of the above environment variables will be used to set the environment.
The value assigned to the environment variable LC_ALL, if set, will be used for all locale categories. LC_ALL is primarily intended for use when a user wishes to make sure that a particular program is executed with one locale only (i.e., no mixed locales).
The value assigned to the environment variable LANG will be used as the value for any of the above variables for which no valid value is assigned. If LANG is set to a valid value, and none of the above variables are set, then the entire environment will be set to the value indicated by LANG.
The information that defines a specific locale must be stored in data files on the system. The information for each category is stored in a file with a name corresponding to the environment variable name. The default location is within a directory under /lib/locale/ISC. The name of the directory is the name of the locale:
/lib
|
/locale
|
/ISC
|
+--------------------+
| | |
locale-1 locale-2 locale-3
|
+----------------------------------+
| | | | | |
| | LC_CTYPE | LC_COLLATE LC_TIME | LC_NUMERIC
| |
LC_MONETARY LC_MESSAGES
Creating a Locale
The following steps are used to create the locale information.
Locales installed under /lib/locale/ISC should be viewed as “public” locales; all others should be considered private. Installation procedures are the same for both private and public locales. Only the system administrator should be able to create, modify, or delete public locales.
As a first step, create a directory with the desired name of the locale within /lib/locale/ISC (or, in case of a private locale, the appropriate directory). Then, the individual categories should be created as described in the following sections.
LC_COLLATE
The information in the LC_COLLATE file is generated via the colldef utility. For details, see the utility description.
LC_CTYPE
The information in the LC_CTYPE file is generated via the chrtbl utility. After executing the chrtbl utility, the generated data file must be copied or moved to the locale directory and given the name of LC_CTYPE. As an example, assuming that the name or the desired locale is fr_FR.8859 and the chrclass value in the character classification table is french, then the following steps should be performed:
$chrtbl sourcename
$cp french /lib/locale/ISC/fr_FR.8859/LC_CTYPE
LC_MESSAGES
The information in the LC_MESSAGES file is in text format and defines the strings associated with the affirmative (“y”) and negative (“n”) responses used by selected utilities. Each line in the text file contains a keyword and a value, separated by space(s) or tab(s). Strings must be enclosed in quotation marks; individual characters can be so enclosed, but it is not required. Lines starting with a # are ignored. The following keywords are recognized:
LC_MESSAGES This keyword must be the first in the file.
yesexpr The value is a regular expression used to evaluate an affirmative response. The regular expression must be enclosed in quote marks.
noexpr The value is a regular expression used to evaluate a negative response. The regular expression must be enclosed in quote marks.
END LC_MESSAGES This keyword must be the last in the file.
Example:
LC_MESSAGES
yesexpr "[Yy][[:alpha:]]*"
noexpr "[Nn].*"
END LC_MESSAGES
LC_MONETARY
The information in the LC_MONETARY file is in text format. Each line in the text file contains a keyword and a value, separated by space(s) or tab(s). Strings must be enclosed in quotation marks; individual characters can be so enclosed, but it is not required. Lines starting with a # are ignored. For a detailed definition of the values, see localeconv(3P). The following keywords are recognized:
LC_MONETARY This keyword must be the first in the file.
int_curr_symbol The value is the four-character string to be used as international currency symbol, enclosed in quote marks.
currency_symbol The value is the character used as currency symbol.
mon_decimal_point
The value is the decimal delimiter used to format monetary values.
mon_thousands_sep
The value is the separator used to format monetary values.
mon_grouping The value is a string of semicolon-separated numbers, as described in localeconv(3P).
positive_sign The string used to indicate a value for a non-negative formatted monetary quantity.
negative_sign The string used to indicate a negative-valued formatted monetary quantity.
int_frac_digits The number of fractional digits (those after the decimal delimiter) to be displayed in an internationally formatted monetary quantity.
frac_digits The number of fractional digits (those after the decimal delimiter) to be displayed in a formatted monetary quantity.
p_cs_precedes Set to 1 or 0 if the currency_symbol respectively precedes or succeeds the value for a non-negative formatted monetary quantity.
p_sep_by_space Set to 1 or 0 if the currency_symbol respectively is or is not separated by a space from the value for a non-negative formatted monetary quantity.
n_cs_precedes Set to 1 or 0 if the currency_symbol respectively is or is not separated by a space from the value for a negative formatted monetary quantity.
n_sep_by_space Set to 1 or 0 if the currency_symbol respectively is or is not separated by a space from the value for a negative formatted monetary quantity.
p_sign_posn Set to a value indicating the positioning of the positive_sign for a non-negative formatted monetary quantity.
n_sign_posn Set to a value indicating the positioning of the negative_sign for a negative formatted monetary quantity.
END LC_MONETARY This keyword must be the last in the file.
Example:
LC_MONETARY
int_curr_symbol "USD "
currency_symbol "$"
mon_decimal_point "."
mon_thousands_sep " "
mon_grouping 3
negative_sign "CR"
int_frac_digits 2
frac_digits 2
p_cs_precedes 0
p_sep_by_space 1
n_cs_precedes 0
n_sep_by_space 1
n_sign_posn 1
END LC_MONETARY
LC_NUMERIC
The information in the LC_NUMERIC file is in text format. Each line in the text file contains a keyword and a value, separated by space(s) or tab(s). Lines starting with a # are ignored. The following keywords are recognized:
LC_NUMERIC This keyword must be the first in the file.
decimal_point The value is the character to be used as decimal delimiter; it may be enclosed in quotation marks.
thousands_sep The value is the character used as the thousands separator; it may be enclosed in quotation marks.
grouping The value is a string of semicolon-separated numbers, as described in localeconv(3P).
END LC_NUMERIC This keyword must be the last in the file.
Example:
LC_NUMERIC
decimal_point "."
thousands_sep " "
grouping 3;3;0
END LC_NUMERIC
LC_TIME
The information in the LC_TIME file is in text format. Each line in the text file contains a keyword and one or more values. The keyword is separated from the values by space(s) or tab(s). Values are separated by semicolons which can have spaces or tabs before or after them. Strings must be enclosed in quotation marks; individual characters can be so enclosed, but it is not required. Lines starting with a # are ignored. Lines can be continued by using a backslash (\) at the end of the line. The following keywords are recognized:
LC_TIME This keyword must be the first in the file.
abday Defines the abbreviated names of the weekdays, starting with Sunday.
day Defines the names of the weekdays, starting with Sunday.
abmon Defines the abbreviated names of the months, starting with January.
mon Defines the names of the months, starting with January.
t_fmt Defines the format of the time string, using the strftime conversion specifiers (see ctime(3P)).
d_fmt Defines the format of the date string, using the strftime conversion specifiers (see ctime(3P)).
d_t_fmt Defines the format of the combined date and time string, using the strftime conversion specifiers (see ctime(3P)).
am_pm Defines the strings used to represent ante meridiem and post meridiem (in that order).
t_fmt_ampm Defines the format of the time string in 12-hour format.
END LC_TIME This keyword must be the last in the file.
Example:
LC-TIME
abday "Sun";"Mon";"Tue";"Wed";"Thu";"Fri";"Sat"
day "Sunday";"Monday";"Tuesday";"Wednesday"; "Thursday";"Friday";"Saturday"
abmon "Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul"; "Aug";"Sep";"Oct";"Nov";"Dec"
mon "January";"February";"March";"April";"May"; "June";"July";"August";"September";"October"; "November";"December"
t_fmt "%H:%M:%S"
d_fmt "%d/%m/%y"
d_t_fmt "%a %b %d %H %M %S %Y"
am_pm "AM";"PM"
t_fmt_ampm "%I:%M:%S %p"
END LC_TIME
Locale Naming Conventions and Usage
X/Open recommends that locale names follow a certain convention. The recommended format is:
language[_territory][.[codeset]][@modifier]
where:
language Indicates the language area, e.g., fr (for French).
territory Indicates the geographical area, e.g., CH (for Switzerland), which controls, for example, monetary editing rules.
codeset Indicates the used code set, e.g., 8859.
modifier Can be used to distinguish between otherwise identical names (for instance between two different collation sequences).
Example:
$LANG=fr_FR.8859
$LC_COLLATE=$HOME/mylocale
In the above declarations, the default locale is French (France), using the 8859-1 codeset. (8859 is used as a synonym for the ISO/IEC 8859-1 codeset, also known as “Latin-1.”) This is the locale chosen for all categories except LC_COLLATE, for which a “private” locale in the directory mylocale is chosen.
FILES
/lib/locale/ISC/* Default directory for locale directory structures (* is the name of the locale).
/lib/locale/ISC/*/LC_COLLATE
Contains LC_COLLATE information.
/lib/locale/ISC/*/LC_CTYPE Contains LC_CTYPE information.
/lib/locale/ISC/*/LC_MESSAGES
Contains LC_MESSAGES information.
/lib/locale/ISC/*/LC_MONETARY
Contains LC_MONETARY information.
/lib/locale/ISC/*/LC_NUMERIC
Contains LC_NUMERIC information.
/lib/locale/ISC/*/LC_TIME Contains LC_TIME information.
SEE ALSO
ctime(3P), localeconv(3P), setlocale(3P), environ(5P).
chrtbl(1M) in the INTERACTIVE UNIX System User’s/System Administrator’s Reference Manual.
colldef(1P) in the International Supplement Guide.
\*U — Version 1.0