locale-gen doesn't work
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?
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. :)
At last I could find the solution by doing some things manually:
-
check which locales are supported :
less /usr/share/i18n/SUPPORTED
-
Add locale to list of generated
(sudo) echo fa_IR.UTF-8 UTF-8 >> /var/lib/locales/supported.d/local
-
Regenerate list (it will invoke locale-gen...)
(sudo) dpkg-reconfigure locales