About the “locale” : Generalities and Practical examples

french flag


This page is a quick reference for locale and language settings under Red Hat based distros.



1 Generalities

The “locale” settings are the set of parameters that tells your system where you are located and therefore which set of characters, date format, currency etc. it should use.

For example if you are located in The United States, your currency should be US Dollars and your date format should be yyyy-mm-dd when in france you should use the euro as currency and the dd-mm-yyyy date format.



2 Querying / modifying locale settings

This chapter will give you some commands to interact or just print your locale settings.

2.1 Querying current locale settings

You can print your actual locale settings by using the naked locale command, this will give you an output like :

$ locale

I am now sure that you all know how french i am ! i am nothing but all french …

Note (about the above output) : Any LC_* variables which are “double-quoted” means that they were not correctly defined but instead they inherit their value from another variable, such as LANG or LC_ALL.

Tips : The -a option for locale command output all available locales.


2.2 Setting up a “per user” language

This can be done by adding a simple parameter to the user’s .bashrc file (if the user’s connection shell is bash, if it is csh, then you will need to edit the user’s .cshrc file), as (for french language support) :

export LANG=fr_FR.UTF-8


2.3 Language file syntax (i18n)

The system default locale parameters of a fedora based Linux are defined in the /etc/sysconfig/i18n file.

The following is an excerpt of my own system (a Red Hat Enterprise Linux Server release 5.5 (Tikanga)) i18n file :


In this example we can see from 2 variables definitions :

  1. The LANG, which define the system-wide default language.
    Note : This parameter may slightly impact your system performance when using processing text tool such as grep.
  2. The SYSFONT, which define the system-wide default font.


An optional parameter can be seen in this file :

  1. The SUPPORTED parameter defines which languages are supported by the system. (not sure what this means, please comment if you do !)



3 About locale variables

3.1 LC_*

Those variables defines multiples parameters such as the date format, the monetary unit, the character set etc.

3.2 LANG

This variable defines the default language used by the computer to interact with the user.

3.3 LC_ALL

This variable should not be used for normal system usage. This variable might come in handy when you want to run a software with specific language settings.

Note : The LC_ALL overwrite any others LC_* variables.



4 Miscellaneous

Here is some miscellaneous tips related to locale / language settings.

4.1 Change your keyboard key mapping

To achieve this sometimes useful feature you just need to type the following in a terminal (e.g : to change to us keyboard) :

(The following tips all comes from this page)

  • e.g to change a keyboard language to US english

    • for a command line session (must be done as root)
      loadkeys us
    • for an X session (using an X server)
      setxkbmap -layout us
    • or a simpler
      setxkbmap us



Tagged on: ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site supports SyntaxHighlighter via WP SyntaxHighlighter. It can highlight your code.
How to highlight your code: Paste your code in the comment form, select it and then click the language link button below. This will wrap your code in a <pre> tag and format it when submitted.