DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

locale(1)


locale -- get locale-specific information

Synopsis

locale [-a | -m] locale [-ck] name ...

Description

The locale command writes information about the current locale environment, or all public locales, to the standard output. For the purposes of this section, a public locale is one provided by the implementation that is accessible to the application.

When locale is invoked without any arguments, it summarizes the current locale environment for each locale category as determined by the settings of the environment variables LANG, LC_ALL, LC_COLLATE, LC_CTYPE, LC_MESSAGES, LC_NUMERIC, and LC_TIME.

When invoked with operands, it writes values that have been assigned to the keywords in the locale categories, as follows:

Options

The following options are supported:

-a
Write information about all available public locales.

-c
Write the names of selected locale categories; see ``Output''. The -c option increases readability when more than one category is selected (for example, via more than one keyword name or via a category name). It is valid both with and without the -k option.

-k
Write the names and values of selected keywords. The implementation may omit values for some keywords; see ``Operands''.

-m
Write names of all charmap source files available on the system for use with localedef(1).

Operands


name
The name of a locale category (as defined in ``Internationalization'' in Programming with system calls and libraries), the name of a keyword in a locale category, or the reserved name charmap. The named category or keyword will be selected for output. If a single name represents both a locale category name and a keyword name in the current locale, the results are unpredictable. Otherwise, both category and keyword names can be specified as name operands, in any sequence.

Environment variables

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 or 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).

LC_MESSAGES
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined. The LANG and LC_* environment variables must specify the current locale environment to be written out; they will be used if the -a option is not specified.

Output

If locale is invoked without any options or operands, the names and values of the LANG and LC_* environment variables described in this document will be written to the standard output, one variable per line, with LANG first, and each line using the following format.

Only those variables set in the environment and not overridden by LC_ALL will be written using this format:

   "variable_name=value"
The names of those LC_* variables associated with locale categories that are not set in the environment or are overridden by LC_ALL will be written in the following format:
   "variable_name=\"implied_value\""
The implied_value is the name of the locale that has been selected for that category, based on the values in LANG and LC_ALL.

The value and implied value shown above will be properly quoted for possible later reentry to the shell. The value will not be quoted using double-quotes (so that it can be distinguished by the user from the implied value case, which always requires double-quotes).

The LC_ALL variable will be written last, using the first format shown above. If it is not set, it will be written as:

   "LC_ALL="
If any arguments are specified:

Exit codes

An exit values of 0 indicates that all the requested information was found and output successfully; an exit code greater than 0 indicates that an error occurred.

Usage

This implementation of locale does not write out the actual values for keywords in the categories LC_CTYPE and LC_COLLATE (except for the char class keyword of LC_CTYPE), but does write out the categories (allowing an application to determine, for example, which character classes are available).

Examples

In the following examples, the assumption is that locale environment variables are set as follows:
   LANG=locale_x
   LC_COLLATE=locale_y
The command locale would result in 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 command LC_ALL=POSIX locale -ck decimal_point would produce:
   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
   non-affirmative processing goes here
   fi

References

localedef(1).
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004