Most modern operating systems have a notion of the “current locale”—that is, the region or country whose localization conventions are honored. These conventions, typically chosen by some runtime configuration mechanism on the computer, affect the way in which programs present data to the user, as well as the way in which they accept user input.
On most Unix-like systems, you can check the values of the locale-related runtime configuration options by running the locale command:
$ locale LANG= LC_COLLATE="C" LC_CTYPE="C" LC_MESSAGES="C" LC_MONETARY="C" LC_NUMERIC="C" LC_TIME="C" LC_ALL="C" $
The output is a list of locale-related environment variables and their current values. In this
example, the variables are all set to the default C
locale, but users can set these variables to
specific country/language code combinations. For example, if one were to
set the LC_TIME
variable to fr_CA
, programs would know to present time and
date information formatted according to a French-speaking Canadian’s
expectations. And if one were to set the LC_MESSAGES
variable to zh_TW
, programs would know to present
human-readable messages in traditional Chinese. Setting the LC_ALL
variable has the effect of changing
every locale variable to the same value. The value of LANG
is used as a default value for any locale
variable that is unset. To see the list of available locales on a Unix
system, run the command locale -a
.
On Windows, locale configuration is done via the “Regional and Language Options” control panel item. There, you can view and select the values of individual settings from the available locales, and even customize (at a sickening level of detail) several of the display formatting conventions.