Linux local command (localization and internationalization)
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.
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:
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:
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:
To change the location setting, simply change the LC_ALL variable:
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:
To change the location: