245

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?

12 Answers 12

338
  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 
    
12
  • 31
    ...then run sudo update-locale Mar 14, 2013 at 23:05
  • 6
    What do you do if it's not supported?
    – Kimble
    Jun 14, 2013 at 9:22
  • 6
    Could you please expand on why are both ru_RU and ru_RU.UTF-8 needed? I don't know much about locales. Mar 3, 2015 at 22:16
  • 18
    If you work with php5-fpm you'll need sudo service php5-fpm restart
    – Stalinko
    Apr 26, 2015 at 8:17
  • 7
    For some reason command sudo locale-gen ru_RU.UTF-8 does nothing for me. As an alternative, one could go and manually edit file vi /etc/locale.gen to uncomment desired locales. Aug 6, 2018 at 12:34
98

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).

4
  • I think that this is the best and most 'Ubuntu' way of doing this Mar 13, 2015 at 21:30
  • 5
    But generating the locales provides stuff like localized date format, decimal separator, character sets etc. The language packs also provides translations, which is not necessarily the intention. Jun 17, 2015 at 22:58
  • 1
    Agree with Oskar. Even stronger if you consider this installation is for a server - most interfaces will be in english anyway. Sep 22, 2015 at 6:16
  • 2
    I was afraid this would also change the current locale, but no. Everything is fine. Looks like the best approch imo. I don't particularly need "translations or other stuff", but if I specifically use a locale for some reason, I expect it to be complete.
    – Balmipour
    Oct 28, 2016 at 10:20
54
  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
    
2
  • 4
    I had to add the second column: echo ru_RU.UTF-8 UTF-8 >> /var/lib/locales/supported.d/local (UTF-8 occurs twice) on Ubuntu 15.04. Otherwise, it works.
    – jfs
    Oct 27, 2015 at 21:45
  • On trusty locale-gen ru_RU.utf8 basically adds ru_RU.UTF-8 UTF-8 to /var/lib/locales/supported.d/local, and well, adds the locale. dpkg-reconfigure locales seems to run locale-gen, which in the lack of arguments installs locales from /var/lib/locales/supported.d/local, the ones not yet installed.
    – x-yuri
    Jun 10, 2021 at 15:36
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.

7

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.

2
  • oh, my locale-gen created a tonns of locales, ignoring locale.gen file. So use this advice with a caution.
    – Dzenly
    Aug 31, 2017 at 2:41
  • The trusty manpage say: "Otherwise it generates all supported locales." Although I'm on trusty right now, and it seems to consult /var/lib/locales/supported.d/local for a list of locales to be generated. Which contradicts the manpage.
    – x-yuri
    Jun 10, 2021 at 15:21
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
1
  • This worked for me. In my case, I had that bad entry error for en_GB locales. I've updated my /var/lib/locales/supported.d/mintlocale file to contain the lines en_GB UTF-8 and en_GB.UTF-8 UTF-8 (the extra UTF-8 was missing). Feb 15, 2019 at 20:28
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:~$ 
0
3

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.

3

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
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

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 [email protected]

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.

0

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.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .