Accueil > Système, Tutoriel > HowTo : Change Locale (Language and Character Set) in Linux

HowTo : Change Locale (Language and Character Set) in Linux

26/04/2021 Categories: Système, Tutoriel Tags:
Print Friendly, PDF & Email

Locales are used in Linux to define which language and character set (encoding) the user uses.

In this article, I’ll show you how to :

  • Check the Current Locale
  • Get the List of Available Locales
  • Add a New Locale
  • Change the Locale for Current Session
  • Change the Locale Permanently
  • Change the Default System’s Locale

Current Locale

Get the information about the current locale environment :

$ locale

Locale is defined in the following format :
<lang>_<territory>.<codeset>[@<modifiers>]
For example : Australian English using the UTF-8 encoding is en_AU.UTF-8

Available Locales

Look for available locales :

$ locale -a

Adding New Locale

If you didn’t find the desired language or encoding, you can search for them in the list of all supported locales :

/usr/share/i18n/SUPPORTED

Generate a new locale by running locale-gen command. For example :

# locale-gen en_US.UTF-8
# locale-gen ru_RU.UTF-8
# locale-gen fr_FR ISO-8859-1

Now you could see it in the list of available locales.
$ locale -a

Change Locale for Current Session

# Set English locale
$ LANG=en_US.utf8
# Set Russian locale
$ LANG=ru_RU.utf8
# Set France locale
$ LANG=fr_FR.iso-8859-15

Change Locale Permanently

Put the following line to bash profile (~/.bashrc or ~/.profile), to change user’s locale permanently :

export LANG=en_US.utf8

Changes will take effect after logout/login.

Change Default System’s Locale

Perform the following steps to permanently change system’s locale.

Edit the file with default locales :

/etc/default/locale

Change the LANG variable:

LANG="en_US.utf8"

Changes will take effect after reboot.

Lire aussi:  nohup: How to launch standalone and independant job
Categories: Système, Tutoriel Tags:
Les commentaires sont fermés.