Linux - locale (LANG, LC environment variable)

> Operating System - Kernel (Windows, Unix, Linux) > Linux / Unix

1 - About

Most UNIX systems use the LANG variable to specify the desired locale but you can use also the setlocale function.

3 - How to

3.1 - Obtain the locale values

To obtain the locale names for your UNIX system, enter the following:

locale -a
[[email protected] ~]$ locale -a | grep -i en
en_AU
en_AU.iso88591
en_AU.utf8
en_BW
en_BW.iso88591
en_BW.utf8
en_CA
en_CA.iso88591
en_CA.utf8
en_DK
en_DK.iso88591
en_DK.utf8
en_GB
en_GB.iso88591
en_GB.iso885915
en_GB.utf8
en_HK
en_HK.iso88591
en_HK.utf8
en_IE
[email protected]
en_IE.iso88591
[email protected]
en_IE.utf8
en_IN
en_IN.utf8
en_NZ
en_NZ.iso88591
en_NZ.utf8
en_PH
en_PH.iso88591
en_PH.utf8
en_SG
en_SG.iso88591
en_SG.utf8
en_US
en_US.iso88591
en_US.iso885915
en_US.utf8
en_ZA
en_ZA.iso88591
en_ZA.utf8
en_ZW
en_ZW.iso88591
en_ZW.utf8
Advertising

3.2 - Obtain the locale values

When invoked without arguments, locale summarizes the current locale environment for each locale category defined by the LC_* environment variables.

[[email protected] ~]$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

3.3 - Set a locale

With the setlocale function

setlocale

4 - Documentation / Reference

os/linux/locale.txt · Last modified: 2018/09/16 12:42 by gerardnico