How to configure locales in Ubuntu 14 LTS, Trusty Tahr

This tutorial will explain how we can configure locales in Ubuntu 14.04.2 LTS, Trusty Tahr from the command line. All commands work under Ubuntu 12 Precise as well.

Contents
1. How to display the ‘Current Settings’
2. How to display the ‘Available Locales’
3. How to adjust locales
4. References/External source

1. How to display the Current Settings

 $ locale
LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL= 

2. How to display the Available Locales

 $ locale -a
C
C.UTF-8
POSIX
fr_FR.utf8 

If one of the desired locales does not appear in the list, then it will need to be installed additionally.

 $ locale-gen en_US.UTF-8
Generating locales...
  en_EN.UTF-8... done
Generation complete. 

To check all the available locales view the file : /usr/share/i18n/SUPPORTED

3. How to adjust locales

The default configurations are stored in the /etc/default/locale file.

 $ cat /etc/default/locale 
LANG=fr_FR.UTF-8 

If the above file doesn’t exist, then it can be generated and adjusted using the following command :

 $ echo "LANG=en_US.utf8" > /etc/default/locale 
$ cat /etc/default/locale 
LANG=en_US.utf8 

You can find a list of all the LC_* environment variables on the official site of ubuntu at help.ubuntu.com
This will be very useful for instance, if a system is required to be operated in French, however the error and system messages will still be displayed in English. This is quite helpful, when we’re looking for errors. For this scenario, we can attempt the following settings to /etc/default/locale file:

 LANG=fr_FR.UTF-8
LC_MESSAGES=POSIX 

4. References/External source

Ubuntu Community Documentation: Locale (help.ubuntu.com)

Feel free to contact us if you believe you’re still facing issues following these steps. Rackhansa Professionals are always ready to help their customers in making their online presence smooth and uninterrupted. Our free webhosting services have also been devised mainly for those entrepreneurs who have just jumped into online business. To know more about our services, please visit our products page to enjoy the cheap hosting plans.