Name

locale — Get locale-specific information

Synopsis

locale [-amvhV]

locale [-ck] NAME

locale [-iusfnU]

locale -h | -V

Options

System information:

  -a, --all-locales    List all available supported locales
  -m, --charmaps       List all available character maps
  -v, --verbose        More verbose output

Modify output format:

  -c, --category-name  List information about given category NAME
  -k, --keyword-name   Print information about given keyword NAME

Default locale information:

  -i, --input          Print current input locale
  -u, --user           Print locale of user's default UI language
  -s, --system         Print locale of system default UI language
  -f, --format         Print locale of user's regional format settings
                       (time, numeric & monetary)
  -n, --no-unicode     Print system default locale for non-Unicode programs
  -U, --utf            Attach \".UTF-8\" to the result

Other options:

  -h, --help           This text
  -V, --version        Print program version and exit

Description

locale without parameters prints information about the current locale environment settings.

The -i, -u, -s, -f, and -n options can be used to request the various Windows locale settings. The purpose is to use this command in scripts to set the POSIX locale variables.

The -i option prints the current input language. This is called the "Input language" and basically equivalent to the current keyboard layout setting.

The -u option prints the current user's Windows UI locale to stdout. In Windows this setting is called the "Display Language".

The -s option prints the systems default instead.

The -f option prints the user's setting for time, date, number and currency. That's equivalent to the setting in the "Formats" or "Regional Options" tab in the "Region and Language" or "Regional and Language Options" dialog.

The -n option prints the system's default language used for applications which don't support Unicode.

With the -U option locale appends the string ".UTF-8" to enforce using UTF-8. Using UTF-8 as codeset is recommended.

Usage example:

bash$ export LANG=$(locale -uU)
bash$ echo $LANG
en_US.UTF-8
bash$ export LC_TIME=$(locale -fU)
bash$ echo $LC_TIME
de_DE.UTF-8

The -a option is helpful to learn which locales are supported by your Windows machine. It prints all available locales and the allowed modifiers. Example:

bash$ locale -a
C
C.utf8
POSIX
af_ZA
af_ZA.utf8
am_ET
am_ET.utf8
...
be_BY
be_BY.utf8
be_BY@latin
...
ca_ES
ca_ES.utf8
ca_ES@euro
catalan
...

The -v option prints more detailed information about each available locale. Example:

bash$ locale -av
locale: af_ZA           archive: /cygdrive/c/Windows/system32/kernel32.dll
-------------------------------------------------------------------------------
 language | Afrikaans
territory | South Africa
  codeset | ISO-8859-1

locale: af_ZA.utf8      archive: /cygdrive/c/Windows/system32/kernel32.dll
-------------------------------------------------------------------------------
 language | Afrikaans
territory | South Africa
  codeset | UTF-8

...

locale: ca_ES@euro      archive: /cygdrive/c/Windows/system32/kernel32.dll
-------------------------------------------------------------------------------
 language | Catalan
territory | Spain
  codeset | ISO-8859-15

locale: catalan         archive: /usr/share/locale/locale.alias
-------------------------------------------------------------------------------
 language | Catalan
territory | Spain
  codeset | ISO-8859-1

...

The -m option prints the names of the available charmaps supported by Cygwin to stdout.

Otherwise, if arguments are given, locale prints the values assigned to these arguments. Arguments can be names of locale categories (for instance: LC_CTYPE, LC_MONETARY), or names of keywords supported in the locale categories (for instance: thousands_sep, charmap). The -c option prints additionally the name of the category. The -k option prints additionally the name of the keyword. Example:

bash$ locale -ck LC_MESSAGES
LC_MESSAGES
yesexpr="^[yY]"
noexpr="^[nN]"
yesstr="yes"
nostr="no"
messages-codeset="UTF-8"
bash$ locale noexpr
^[nN]