255

I currently have those locales:

locale -a

C
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZW.utf8
POSIX

How can I install ru_RU locale to my server?

Jorge Castro
  • 73,717
Silver Light
  • 2,647

12 Answers12

355
  1. Check which locales are supported:

    locale -a
    
  2. Add the locales you want (for example ru):

    sudo locale-gen ru_RU
    sudo locale-gen ru_RU.UTF-8
    
  3. Run this update command:

    sudo update-locale 
    
Melebius
  • 11,750
PocketSam
  • 4,159
108

I would go another route, which is IMO better suited to the Ubuntu style. Use the packages provided. There are packages for each locale, and they do all the work for you... no need to edit /var files, which I always believed were not meant to be edited manually.

sudo apt-get install language-pack-XX

where XX stands for the language code. Installing a language will install also all the country-specific variants (for example, installing language-pack-it will install it_CH.utf8 and it_IT.utf8, installing for NL will install nl_AW, nl_AW.utf8, nl_BE.utf8 and nl_NL.utf8).

Palantir
  • 2,052
55
  1. check which locales are supported :

    less /usr/share/i18n/SUPPORTED
    
  2. Add locale to list of generated

    echo ru_RU.UTF8 >> /var/lib/locales/supported.d/local
    
  3. Regenerate list (it will invoke locale-gen...)

     sudo dpkg-reconfigure locales
    
19

I've found locale-gen to be your friend. as in (adding hebrew utf8 for example):

root@world:~# locale-gen he_IL.UTF-8

you can even rehash it like so:

root@world:~# dpkg-reconfigure locales

and check that you did good:

root@world:~# locale -a

I found this solution way simpler than adding stuff to text files, even though it is what it does.

boazr
  • 191
9

Modify /etc/locale.gen, uncommenting or adding the locales you wish generated. Then run sudo locale-gen.

You can check that the locales are added with locale -a, which will show all locales.

hunse
  • 191
6
echo ru_RU.UTF8 >> /var/lib/locales/supported.d/local

I get the following message at point 3: "Error: Bad entry 'ru_RU.UTF8'"

This work for me:

echo ru_RU.UTF-8 UTF-8 >> /var/lib/locales/supported.d/local
user123
  • 61
5

Use Ubuntu language packs. All supported languages are available in default repositories:

apt-cache search language-pack

A full example of locale switching in Ubuntu (server) version:

jani@example:~$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.1 LTS"

All available (i.e. already installed) locales can be listed with:

locale -a

My current locale is en_IE:

jani@example:~$ locale
LANG=en_IE.UTF-8
LANGUAGE=
LC_CTYPE="en_IE.UTF-8"
LC_NUMERIC="en_IE.UTF-8"
LC_TIME="en_IE.UTF-8"
LC_COLLATE="en_IE.UTF-8"
LC_MONETARY="en_IE.UTF-8"
LC_MESSAGES=POSIX
LC_PAPER="en_IE.UTF-8"
LC_NAME="en_IE.UTF-8"
LC_ADDRESS="en_IE.UTF-8"
LC_TELEPHONE="en_IE.UTF-8"
LC_MEASUREMENT="en_IE.UTF-8"
LC_IDENTIFICATION="en_IE.UTF-8"
LC_ALL=
jani@example:~$ date
Sat Nov  1 15:36:51 UTC 2014
jani@example:~$

Because I didn't have ru locales I have to install ru language pack:

jani@example:~$ sudo apt-get -y install language-pack-ru
[..]
Generating locales...
  ru_RU.UTF-8... done
  ru_UA.UTF-8... done
Generation complete.
jani@example:~$ 

Now the ru locales are available. The system default locale is set by editing /etc/default/locale:

jani@example:~$ sudo vi /etc/default/locale
# Created by cloud-init v. 0.7.5 on Mon, 27 Oct 2014 18:46:13 +0000
LANG="ru_RU.UTF-8"
LC_MESSAGES=POSIX
jani@example:~$

Re-login and check your brand new locale:

jani@example:~$ locale
LANG=ru_RU.UTF-8
LANGUAGE=
LC_CTYPE="ru_RU.UTF-8"
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_MESSAGES=POSIX
LC_PAPER="ru_RU.UTF-8"
LC_NAME="ru_RU.UTF-8"
LC_ADDRESS="ru_RU.UTF-8"
LC_TELEPHONE="ru_RU.UTF-8"
LC_MEASUREMENT="ru_RU.UTF-8"
LC_IDENTIFICATION="ru_RU.UTF-8"
LC_ALL=
jani@example:~$ date
Сб. нояб.  1 15:43:45 UTC 2014
jani@example:~$ 
4

For a small server that did not support the locale I needed (locale -a did not list it), all I had to do was run

sudo dpkg-reconfigure locales

which provided text-based dialogues that I could select from (page up/down, up/down, space to select, tab to OK, and Enter to save). It automatically regenerated the locales.

As others have stated, you will need to restart any process that needs the new locale.

Walf
  • 452
4

If you don't have locales installed:

apt-get update && apt-get install locales

After that, just add the desired locale

sudo locale-gen pt_BR
1

In addition to the other answers…

If for some reason you need to add a locale that isn't listed in /usr/share/i18n/SUPPORTED (the same list is used as base for /etc/locale.gen and sudo dpkg-reconfigure locales), you can manually call localedef, e.g.:

sudo localedef -c -i uk_UA -f CP1251 uk_UA.CP1251

(/usr/share/i18n/SUPPORTED contains only UTF-8 and KOI8-U codesets for uk_UA but not CP1251.)

Sasha
  • 123
0
  1. Check which locales are already supported in your distribution. Open or cat the file /usr/share/i18n/SUPPORTED and copy the desired locale to be added.
  2. on terminal enter sudo locale-gen locale_name.

    For example sudo locale-gen de_DE.iso885915@euro

  3. enter sudo update-locale

  4. Check if the locale is installed with locale -a

BugShotGG
  • 326
0

Couldn't comment so I have to add this as the answer.

I needed to add a 'special' type of locale sr_RS.utf8@latin in Ubuntu.

Command:

sudo locale-gen sr_RS.utf8@latin

does not add the @latin to the available locales. In order to succeed in that the command should look like this:

sudo locale-gen sr_RS@latin.utf8

The command:

sudo locale -a

now shows:

sr_RS
sr_RS@latin
sr_RS.utf8
sr_RS.utf8@latin

Pay attention to the syntax difference between the result of locale -a and the way it is added by locale-gen commands.