178

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?

10 Answers 10

254
  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 
    
  • 26
    ...then run sudo update-locale – Justin Force Mar 14 '13 at 23:05
  • 3
    What do you do if it's not supported? – Kimble Jun 14 '13 at 9:22
  • 4
    Could you please expand on why are both ru_RU and ru_RU.UTF-8 needed? I don't know much about locales. – Sopalajo de Arrierez Mar 3 '15 at 22:16
  • 15
    If you work with php5-fpm you'll need sudo service php5-fpm restart – Stalinko Apr 26 '15 at 8:17
  • 3
    This was exactly what I needed, but I had to restart Apache to get it working...thanks! – Jabari Jun 4 '15 at 18:53
53

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

  • I think that this is the best and most 'Ubuntu' way of doing this – Luke Madhanga Mar 13 '15 at 21:30
  • 4
    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. – Oskar Berggren Jun 17 '15 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. – igorsantos07 Sep 22 '15 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 '16 at 10:20
43
  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
    
  • 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 '15 at 21:45
16

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.

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
  • 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). – Samir Aguiar Feb 15 at 20:28
4

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:~$ 
2

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.

  • oh, my locale-gen created a tonns of locales, ignoring locale.gen file. So use this advice with a caution. – Dzenly Aug 31 '17 at 2:41
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 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.

-2

I did things in a similar way to apply the locale system wide without rebooting or having to log out.

First, download the language pack:

sudo apt-get install language-pack-ru-base

Next, check which versions are supported:

less /usr/share/i18n/SUPPORTED | grep ru_RU

Now, apply the result (almost always use the UTF-8 version for just about any language!):

echo 'ru_RU.UTF-8 UTF-8' | sudo tee /var/lib/locales/supported.d/local
sudo dpkg-reconfigure locales

Finally, update your defaults file, source it, and then you're done:

echo 'LANG=ru_RU.UTF-8' | sudo tee /etc/default/locale

apply the changes to the system:

. /etc/default/locale
LANGUAGE=ru_RU.UTF-8

and check your results:

locale
  • Note: If you are running regular Ubuntu and not Ubuntu server, the changes won't carry over beyond the console (if you decide to open a new tab or close the terminal) until after the next time you login. However, using Ubuntu server you typically have to sign in to open a new console anyway so it shouldn't matter. – mchid Dec 11 '14 at 21:08
  • This Question is tagget with server. And who and why downvoted this one, please explain. – Nikos Alexandris Nov 22 '15 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.