5

As I need my locale which is fa_IR.UTF-8 on my Ubuntu Server, I'm trying to install it through (sudo) locale-gen "fa_IR.UTF-8" but I don't get any output:

user@s1:~# sudo locale-gen "fa_IR.UTF-8"
user@s1:~#

AND IT DOESN'T ADD ANY LOCALE to my locales!

When I'm trying to install new locales on my Ubuntu Desktop I don't get this error and It works well! as follows:

user@s1:~# sudo locale-gen "fa_IR.UTF-8"
Generating locales...
  fa_IR.UTF-8... done
Generation complete.
user@s1:~# 

Please help me what's the problem and what shall I do?

6
  • You should probably get a supported release of Ubuntu, such as 14.04 or 15.10, and see where that gets you. – TheWanderer Apr 3 '16 at 23:09
  • Ubuntu 13.04 reached end of live on 2014-01-27 and isn't supported any more. Please use a more current version of Ubuntu. – Florian Diesch Apr 3 '16 at 23:10
  • Dear @Zacharee1, You're right. But I have this OS with lots of customization under production! It's very hard to migrate! So, I'm looking for such a solution. – AbdolHosein Apr 3 '16 at 23:14
  • Dear @FlorianDiesch – AbdolHosein Apr 3 '16 at 23:14
  • We can't help you, as defined by the help center. – TheWanderer Apr 3 '16 at 23:15
3

At last I could find the solution by doing some things manually:

  1. check which locales are supported :

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

    (sudo) echo fa_IR.UTF-8 UTF-8 >> /var/lib/locales/supported.d/local
    
  3. Regenerate list (it will invoke locale-gen...)

     (sudo) dpkg-reconfigure locales
    
2
  • This made me curious. The entry "fa_IR UTF-8" was already in SUPPORTED, but I could reproduce the failure (on 15.10). However, sudo locale-gen fa_IR worked. This indicates a bug in the locale-gen script. – Gunnar Hjalmarsson Apr 4 '16 at 0:31
  • I would guess that the reason why sudo locale-gen "fa_IR.UTF-8" worked on your desktop is that you already had installed the Persian language. – Gunnar Hjalmarsson Apr 4 '16 at 0:42
3

This happened because the names of quite a few UTF-8 locales in /usr/share/i18n/SUPPORTED don't include the codeset part ".UTF-8", and fa_IR is one of those.

$ grep -E '[a-z]+_[A-Z]+ UTF-8' /usr/share/i18n/SUPPORTED | grep fa
fa_IR UTF-8

In Ubuntu 16.04 the locale-gen script has been changed, so the user doesn't need to be aware of the exact naming in SUPPORTED. Hence in 16.04 this will work:

sudo locale-gen fa_IR.UTF-8

For previous Ubuntu versions, the simplest way to create one of these locales is to use the exact name according to SUPPORTED, for example:

sudo locale-gen fa_IR

So, AbdolHosein, your question helped us improve Ubuntu. Thank you for that. :)

0

As I understand it according to the man-pages, local-gen does not take any parameter, so e.g. sudo locale-gen "de_DE.UTF-8" does not do anything.

From man locale-gen:

locale-gen is a program that reads the file /etc/locale.gen and invokes localedef for the chosen localisation profiles. Run locale-gen after you have modified the /etc/locale.gen file.

The solution was simply to modify /etc/locale.gen accordingly using:

echo "de_DE.UTF-8 UTF-8" | sudo tee -a /etc/locale.gen
sudo locale-gen de_DE.UTF-8

Update: According to Gunnar Hjalmarsson´s comment arguments are possible in Ubuntu, but not reflected in the man page. This answer still might be relevant for people who configure other systems from their ubuntu machine and wonder, why they don't behave as expected (as happened to me).

2
  • Thanks for the update. I removed my down vote. ;) If you look at the script cat /usr/sbin/locale-gen you can see that it takes arguments. But the fact that the modifications are not reflected in the man page is a glibc bug (which has been present for many cycles...). – Gunnar Hjalmarsson Jun 3 '20 at 23:19
  • Thanks for removing the downvote :) and also for clarifying! – T-Dawg Jun 3 '20 at 23:42

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.