what are duty of locale and locale-gen commands?

Solution 1:

From Wikipedia :

In computing, a locale is a set of parameters that defines the user's language, country and any special variant preferences that the user wants to see in their user interface. Usually a locale identifier consists of at least a language identifier and a region identifier.

The locale programs will output a set of shell variables and their values. These are the variables that alter the behaviour of some commands regarding the language, character sets usage and so on. From my system :

benoit@thorgal:~s locale
LANG=en_US.UTF-8
LANGUAGE=
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=
benoit@thorgal:~$

This tells those commands, which listen, to use American English and UTF8 encoding for the special characters. If I change the value of LANG and put fr_FR.UTF-8 instead, then commands, that support it, will write their output in French instead of English. Of course, only, if the French translation is installed.

For the locale-gen command, I think that the first paragraph of its man page is self-explaining :

Compiled locale files take about 50MB of disk space, and most users only need few locales. In order to save disk space, compiled locale files are not distributed in the locales package, but selected locales are automatically generated when this package is installed by running the locale-gen program.

When you run locale-gen or locale-gen <locale code> you compile the needed locale file(s), allowing commands to use the locale specified within the environments variables displayed by locale.

Example: locale-gen en_US.UTF8

You can get the available locale codes by using the command locale -a.