The locale command writes information about the current locale or other public locales to the standard output. In the following section, a public environment is an environment provided by the implementation that the application can access.
If locale is called without any arguments, it summarizes the current locale for each environment category as determined by the settings of the environment variables.
If the command is called with operands, it outputs values assigned to the keywords in the environment categories as follows:
If a keyword name is specified, the keyword as well as the category containing the keyword is output.
If a category name is specified, the category as well as all the keywords contained in it are output.
Syntax
Format 1: | locale[ -a| -m] |
Format 2: | locale[ -ck] name... |
Options
Outputs information about all available public locales. The locales available include POSIX.
Outputs the selected environment categories (see “Standard ouptput (stdout)”).
Outputs the names and values of the selected keywords.
Outputs the character map name. name The name of the environment category (see localedef on "localedef define local environment"), the name of a keyword in an environment category or the reserved name charmap. The specified category or the specified keyword can be specified as name operands in any order. |
Locale
The following environment variables affect the execution of locale: LANG Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files), the classification of characters as upper- to lower-case, and the mapping of characters from one case to the other. LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES. |
File
Standard ouptput (stdout)If locale is called without options or operands, the names and values of the LANG and LC_* environment variables are written to the standard output. One line is used for every variable, LANG is output first. Only variables set in the environment and not overwritten by LC_ALL are output in the following format:
The names of the LC_* variables not set in the environment or overwritten by the LC_ALL variable are output in the following format:
implied_value is the name of the locale selected by the implementation for this category based on the values in LANG and LC_ALL. value and implied_value are enclosed in single quotes so they can be reused as an entry some time in the future. value is not enclosed in double quotes (to differentiate it from implied_value, which is always enclosed in double quotes). The LC_ALL variable is output last, using the first format outlined above. If this variable is not set, it is output in the following format:
The following points apply when specifying arguments:
|
Exit status
0 | All the information requested was found and output. |
>0 | An error occured. |
Example
The examples are based on the following locales:
The locale command would have the following output: LANG=locale_x LC_CTYPE="locale_x" LC_COLLATE=locale_Y LC_TIME="locale_x" LC_NUMERIC="locale_x" LC_MONETARY="locale_x" LC_MESSAGES="locale_x" LC_ALL= The
The following command shows a locale application that can be used to determine whether a response entered by a user is a yes-response (affirmation): if printf "%s\n" "$response" | grep -Eq "$(locale yesexpr)" then affirmative processing goes here else non-affirmative processing goes here fi |
See also
localedef |