locale — Get locale-specific information
Format
locale [–a|–m]locale [–ck] name …
Description
locale displays information about the current locale and all locales accessible to the current application. locale searches directory /usr/lib/nls/locale for all the compiled locales.
Invoking locale with no options or operands displays the values of the LANG and LC_* environment variables. If a LC_* variable is not set or is overridden by LC_ALL, locale displays its implied value in double quotes.
The operand name can be a category name, keyword name, or the reserved name charmap. If it is a category name, locale selects the given category and all keywords within it for output. If name is a keyword name, locale selects the given keyword and its category for output. If name is charmap, locale displays the name of the charmap used with the localedef –f option when the locale was created.
Options
- –a
- Displays information about all accessible locales including POSIX
and the POSIX locale. Note: Some of the accessible locales that are displayed will only work in specific environments. For example, the XPLINK locales will not work in the z/OS® shell environment. When using this information to specify a locale, the convention is to use the descriptive locale name. See the section on locale naming conventions in z/OS XL C/C++ Programming Guide.
- –c
- Displays the names of selected categories.
- –k
- Displays the names of selected keywords. If you do not specify the –k option, locale displays the values of selected keywords but not their names. With –k, strings are written in an unambiguous form using the escape character from the current locale.
- –m
- Displays a list of all available character maps.
The following list contains valid locale keywords:
- abday
- Abbreviated day names
- abmon
- Abbreviated month names
- alpha
- All alphabetic characters (upper and lower case)
- am_pm
- A.m. and p.m. string
- backslash
- Encoding of \
- blank
- How a blank is represented
- character-collation
- The collating sequence
- charmap
- Mapping of character symbols to actual character encodings
- circumflex
- Encoding of ^
- cntrl
- Control characters
- codeset
- Same as code_set_name
- code_set_name
- Name of the coded character set used
- commercial_at
- Encoding of @
- currency_symbol
- Local currency symbol of the current locale
- d_fmt
- Date format
- d_t_fmt
- Date and time format
- day
- Full day names
- decimal_point
- Decimal-point characters
- digit
- All numeric characters
- dollar_sign
- Encoding of $
- daylight_name
- The name of the daylight saving time zone (DST). The value will be overwritten if it is different from the keyword setting defined by the TZ environment variable.
- end_day
- Day of the week when daylight saving time (DST) ends. The value will be overwritten if it is different from the keyword setting defined by the TZ environment variable.
- end_month
- Week of the month when daylight saving time (DST) ends. The value will be overwritten if it is different from the keyword setting defined by the TZ environment variable.
- end_time
- Number of seconds after midnight when daylight saving time (DST) ends. The value will be overwritten if it is different from the keyword setting defined by the TZ environment variable.
- end_week
- Month of the year when daylight saving time (DST) ends. The value will be overwritten if it is different from the keyword setting defined by the TZ environment variable.
- exclamation_mark
- Encoding of !
- frac_digits
- Number of digits to the right of the decimal place in monetary quantities
- graph
- Graphic characters
- grave_accent
- Encoding of `
- grouping
- String indicating the size of each group of digits in formatted nonmonetary quantities
- int_curr_symbol
- International currency symbol for the current locale
- int_frac_digits
- The number of displayed digits to the right of the decimal place for internationally formatted monetary quantities
- left_brace
- Encoding of {
- left_bracket
- Encoding of [
- lower
- Lowercase alphabet
- mb_cur_max
- Maximum number of bytes used to represent a character
- mon
- Full month names
- mon_decimal_point
- Decimal-point character used to format monetary quantities
- mon_grouping
- String indicating the size of each group of digits in formatted monetary quantities
- mon_thousands_sep
- Separator for digits in formatted monetary quantities
- n_cs_precedes
- 1 if the currency_symbol precedes the value for a negative formatted monetary quantity; 0 if it does not
- n_sep_by_space
- 1 if the currency_symbol is separated by a space from the value of a negative formatted monetary quantity; 0 if it does not; 2 if a space separates the symbol and the sign string–if adjacent
- n_sign_posn
- Value indicating the position of the negative_sign for a negative formatted monetary quantity
- negative_sign
- String indicating the negative sign used in monetary quantities
- noexpr
- Expression for negative
- number_sign
- Encoding of #
- p_cs_precedes
- 1 if the currency_symbol precedes the value for a nonnegative formatted monetary quantity; 0 if it does not
- p_sep_by_space
- 1 if the currency_symbol is separated by a space from the value of a nonnegative formatted monetary quantity; 0 if it does not; 2 if a space separates the symbol and the string–if adjacent
- p_sign_posn
- Value indicating the position of the positive_sign for a nonnegative formatted monetary quantity
- positive_sign
- String indicating the positive sign used in monetary quantities
- Printable characters
- punct
- Punctuation characters
- right_brace
- Encoding of }
- right_bracket
- Encoding of ]
- shift
- DST time shift in seconds. The value will be overwritten if it is different from the keyword setting defined by the TZ environment variable.
- space
- How white space is represented
- start_day
- Day of the week when daylight saving time (DST) starts. The value will be overwritten if it is different from the keyword setting defined by the TZ environment variable.
- start_month
- Month of the year when daylight saving time (DST) starts. The value ranges from 1 through 12. The value will be overwritten if it is different from the keyword setting defined by the TZ environment variable.
- start_time
- Number of seconds after midnight when daylight saving time (DST) starts. The value will be overwritten if it is different from the keyword setting defined by the TZ environment variable.
- start_week
- Week of the month when daylight saving time (DST) starts. The value will be overwritten if it is different from the keyword setting defined by the TZ environment variable.
- t_fmt
- Time format
- t_fmt_ampm
- Long date format
- tilde
- Encoding of ~
- timezone_difference
- Time zone difference in minutes. The value will be overwritten if it is different from the keyword setting defined by the TZ environment variable.
- timezone_name
- Time zone name. The value will be overwritten if it is different from the keyword setting defined by the TZ environment variable.
- tolower
- Uppercase to lowercase conversion
- thousands_sep
- Character used to separate groups of digits to the left of the decimal-point character in formatted nonmonetary quantities
- toupper
- Lowercase to uppercase conversion
- uctname
- Coordinated Universal Time. The value will be overwritten if it is different from the keyword setting may be overridden if TZ is set.
- upper
- Uppercase alphabet
- vertical_line
- Encoding of |
- xdigit
- Hexadecimal digits
- yesexpr
- Expression for affirmative
Examples
LANG=locale_x
LC_COLLATE=locale_y
- The command:
produces the following output:locale
LANG=locale_x LC_CTYPE="locale_x" LC_COLLATE=locale_y LC_TIME="locale_x" LC_NUMERIC="locale_x" LC_MONETARY="locale_x" LC_SYNTAX="locale_x" LC_TOD="locale_x" LC_MESSAGES="locale_x" LC_ALL=
- The command:
produces:LC_ALL=POSIX locale -ck decimal_point
LC_NUMERIC decimal_point="."
- The following command shows an application of locale to
determine whether a user supplied response is affirmative:
if printf "s%\n" "$response" | grep -Eq "$(locale yesexpr)" then affirmative processing goes here else nonaffirmative processing goes here fi
Environment variables
- TZ
- Contains the time zone to be used when displaying date and time strings.
Localization
- LANG
- LC_ALL
- LC_CTYPE
- LC_MESSAGES
- LC_SYNTAX
- NLSPATH
See Localization for more information.
Exit values
- 0
- Successful completion
- 1
- An error occurred
- 2
- A usage message was printed
Portability
POSIX.2, UNIX System V.
Related information
localedef