Categories: Time and Location

Linux local command (localization and internationalization) [Basic Guide]

The Linux local command works with the environmental variables that define the internationalization of the system, such as characters, dates, and numbering.

Linux maintains a list of environmental variables to define the internationalization standards of language, number format, time format, date format, currency format, among others.

The variables are:

  • LC_COLLATE: defines character or string grouping information;
  • LC_CTYPE: defines the type of character encoding;
  • LC_MONETARY: defines how numbers are written, whether semicolons are used to separate houses;
  • LC_MESSAGES : defines the format for affirmative and negative answers;
  • LC_NUMERIC: defines a list of rules and symbols for the formatting of non-numeric monetary information;
  • LC_TIME: defines how times are written;
  • LC_ALL: defines a standard that It has the other definitions above.

Local

The locale command reports these environmental variables.

$ locale 
lang=pt_BR.UTF-8
LANGUAGE=
lc_ctype="pt_br.utf-8"
lc_numeric="pt_br.utf-8"
lc_time="pt_br.utf-8" lc_br.utf-8" lc_br.utf-8"

lc_monetary="pt_br.utf-8" lc_messages="pt_br.utf-8" lc_br.utf-8"
lc_br.utf-8" lc_br.utf-8"
lc_messages="pt_br.utf-8" lc_br.utf-8"
lc_br.utf-8" UTF-8" LC_NAME="en_BR.UTF-8"
LC_ADDRESS="en_BR.UTF-8"

LC_TELEPHONE=”PT_BR.UTF-8″
LC_MEASUREMENT=”PT_BR.UTF-8″
LC_IDENTIFICATION=”PT_BR.UTF-8″
LC_ALL=pt_BR.UTF-8

The LC_ALL variable can be used to configure all the others.

The “-a” option provides the list of possible locations:

$ local -a en_US.utf8 pt_BR.utf8

The desired location may not always be available in the system. If it does not appear with the “-a” option in the locale command, it is necessary to generate the location.

To see the list of all locations that can be generated, check the contents of the /etc/locale.gen file:

$ cat /etc/locale.gen # AA_Dj ISO-8859-1 # AA_dj.UTF-8 UTF-8 # AA_er UTF-8 (...)

To generate the desired location and be able to use it in the LC_ALL variable, the locale-gen command is used to generate the location:

$ locale-gen pt_BR.UTF-8 
Generating locals (this might take a while)...
pt_BR.UTF-8... done
Generation complete.

To change the location setting, simply change the LC_ALL variable:

$ export LC_ALL=en_BR.UTF-8

Since the location is configured by environment variables, they must be in the shell load script or in the profile for them to be permanent in the system.

localectl command

The systemd localectl service can be used to query and change the system’s location and keyboard layout settings.

This service can be used to control the language settings of the system services and the user interface before the user logs in.

Example:

To view the configured location:

$ localectl status System Locale: lang=en_US.UTF-8 VC Keymap: n/a X11 Layout: n/a

To change the location:

$ sudo localectl set-locale lc_time=EN_IN.UTF-8

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Share
Published by
Uirá Endy Ribeiro

Recent Posts

Sudo command on Linux (privilege scale) [Basic Guide]

The sudo command on Linux executes a given command as if it were another user.…

2 years ago

SS command on Linux (investigate the network) [Basic Guide]

The ss command on Linux is extremely useful for investigating sockets, providing various information about…

2 years ago

Free Linux command (memory usage) [Basic Guide]

Free Linux command shows the amount of total memory in use and available, as well…

2 years ago

Linux while command (loop – while) [Basic Guide]

The shell has structures for testing conditions and executing certain program sequences several times (loop),…

2 years ago

Linux fstab file (disk mount setup) [Basic Guide]

The /etc/fstab file stores the configuration of which devices should be mounted and what is…

2 years ago

Netcat command on Linux (Swiss network knife) [Basic Guide]

The Netcat Command in Linux or nc is a utility used to do “almost anything”…

2 years ago

This website uses cookies.