locale(1) locale(1)
NAME
locale - call up information about the locale
SYNOPSIS
locale [-a|-m] [-v]
locale [-l locale]
locale [-ckv] [-l locale] name ...
DESCRIPTION
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 (see also the XBD specification, Chapter 5,
Locale).
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.
OPTIONS
-a Outputs information about all available public locales. The
locales available include POSIX.
-c Outputs the selected environment categories; see STDOUT. The -c
option improves legibility if several categories are selected
(e.g. using several keyword names or a category name). This
option is valid with or without the specification of the -k
option.
-k Outputs the names and values of the selected keywords.
-l locale
Outputs information on the public locale locale.
-m Outputs the character map name.
-v Outputs additional titles for the -a and -m options.
Page 1 Reliant UNIX 5.44 Printed 11/98
locale(1) locale(1)
name The name of the environment category as defined in the XBD speci-
fication, Chapter 5, Locale, the name of a keyword in an environ-
ment category or the reserved name charmap. The specified
category or the specified keyword can be specified as name
operands in any order.
ENVIRONMENT VARIABLES
The following environment variables have an effect on the execution of
locale:
LANG Specifies a default value for the locale variable that is unset
or null. If LANG is unset or null, the corresponding locale
default value is used. If the locale variable contains an invalid
setting, locale behaves as if no variables had been set.
LCALL
If this value is set, i.e. is not empty, this value overwrites
the values of all other locale variables.
LCCTYPE
Determines the locale for the interpretation of byte sequences as
characters (e.g. single-byte as opposed to multibyte characters
in arguments).
LCMESSAGES
Determines the format and content of error messages.
NLSPATH
Determines the position of the message catalog for the processing
of LCMESSAGES.
The LANG, LC* and NLSPATH environment variables determine the current
locale.
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 LCALL
are output in the following format:
"%s=%s\n", variablename, value
The names of the LC* variable not set in the environment or overwrit-
ten by the LCALL variable are output in the following format:
"%s=\"%s\"\n", variablename, impliedvalue
impliedvalue is the name of the locale selected by the implementation
for this category based on the values in LANG and LCALL.
Page 2 Reliant UNIX 5.44 Printed 11/98
locale(1) locale(1)
value and impliedvalue 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 impliedvalue, which is always
enclosed in double quotes).
The LCALL variable is output last, using the first format outlined
above. If this variable is not set, it is output in the following format:
"LCALL=\n"
The following points apply when specifying arguments:
1. If the -a option is set, the names of all the public locales are
output in the following format:
"%s\n", localename
2. If the -c option is specified, the names of all the selected
categories are output in the following format:
"%s\n", categoryname
If keywords were also selected, these are output immediately after
the category to which they belong.
If the -c option is not specified, only the keywords and not the
category names are output.
3. If the -k option is specified, the names and values of the selected
keywords are output. If the value is non-numeric, it is output in
the following format:
"%s=\"%s\"\n", keywordname, keywordvalue
For the charmap keyword, the name of the character map is output if
a character map was specified using the localedef -f option during
the creation of the locale. charmap is used as keywordname here.
Numeric values are output in one of the following formats:
"%s=%d\n", keywordname, keywordvalue
"%s=%c%o\n", keywordname, escapecharacter, keywordvalue
"%s=%cx%x\n", keywordname, escapecharacter, keywordvalue
escapecharacter is the character defined by the escapechar key-
word in the current locale (see XBD specification, Section 5.3,
Locale Definition).
Keyword values that are combined (list entries) are separated by
semicolons in the output. If the keyword values contain semicolons,
double quotes, backslashes, and/or control characters, these char-
acters are escaped using a preceding escape character.
Page 3 Reliant UNIX 5.44 Printed 11/98
locale(1) locale(1)
4. If the -k option is not specified, the values of all the keywords
are output in the following format:
"%s\n", keywordvalue
For the charmap keyword, the name of the character map is output
(if available).
5. If the -m option is specified, a list of all the available charac-
ter maps is output in the following format:
"%s\n", charmap
The output can be used as an argument for the localedef -f option.
EXIT STATUS
0 All the information requested was found and output.
>0 An error occurred.
EXAMPLES
The examples are based on the following locales:
LANG=localex
LCCOLLATE=localey
The locale command would have the following output:
LANG='localex'
LCCOLLATE='localey'
LCCTYPE="localex"
LCMESSAGES="localex"
LCMONETARY="localex"
LCNUMERIC="localex"
LCTIME="localex"
LCALL=
The LCALL=POSIX locale -ck decimalpoint command would create the
following output:
LCNUMERIC
decimalpoint="."
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):
Page 4 Reliant UNIX 5.44 Printed 11/98
locale(1) locale(1)
if printf "%s\n" "$response" | grep -Eq "$(locale yesexpr)"
then
affirmative processing goes here
else
non-affirmative processing goes here
fi
SEE ALSO
localedef(1).
XBD specification, Section 5.3, Locale Definition
Page 5 Reliant UNIX 5.44 Printed 11/98