Internationalization and localization are two concepts that allow a computer to store information one way but display it in a way that suits the conventions of the user. Internationalization allows a system to display information in different ways, and localization is a process that bundles up all the regional changes for a single location into a locale.
Each locale file contains instructions on how to display or translate a variety of items:
- Addresses: Ordering of various parts in zip code format.
- Collation: How to sort, such as the ordering of accented characters or whether capitalized words are grouped together or separately from lowercase.
- Measurement: Display of various units.
- Messages: Translations for system messages and errors.
- Monetary: How currency symbols are displayed and named.
- Names: Conventions for displaying people’s names.
- Numeric: How to display numbers such as the thousands and decimal separators.
- Paper: Paper sizes used in the country.
- Telephone: How telephone numbers are displayed.
- Time: Date and time formats, such as the ordering of year, month, and date, or 24-hour clock versus using a.m. and p.m.
These locale files are usually distributed with the operating system as separate packages to save on space. If you don’t need the translations, you can generate the rest of the items without installing packages by using locale-gen on systems that support it. For example:
# locale-gen fr_FR.UTF-8 Generating locales... fr_FR.UTF-8... done Generation complete.
# locale -a | grep FR fr_FR.utf8
If you encounter below error while running the locale-gen command:
locale-gen: command not found
you may install the locales package as per your choice of distribution.
Distribution | Command |
---|---|
Debian | apt-get install locales |
Ubuntu | apt-get install locales |
Arch Linux | pacman -S glibc |
Kali Linux | apt-get install locales |
CentOS | yum install glibc |
Fedora | dnf install glibc |
Raspbian | apt-get install locales |
Internationalization in Linux is handled with the GNU gettext library. If programmers write their applications with that library and annotate their messages correctly, the user can change the behavior with environment variables.
Multiple things can be localized, such as numbers and messages, and gettext has a series of environment variables that it checks to see which locale is appropriate. In order, these are:
- LANGUAGE
- LC_ALL
- LC_XXX
- LANG