17

How do I set up a global locale for the computer?

I have recently installed Kubuntu 14.04LTS in english but since I am in Spain, I chose Spain as a country and then changed locale options so that I get all country specific configuration such as digit grouping, decimal separator, date format, etc. I also added the spanish language.

Now all applications complain that locale is wrong. check-language-support tells me I'm using en_ES.UTF-8 as system's locale, and that locale is indeed wrong, there is no locale for english language in Spain.

I tried using Kubuntu's country/region & language settings but it doesn't fix it. I tried using export LANG=en_GB.UTF-8 and export LC_ALL=en_GB.UTF-8 and then sudo dpkg-reconfigure locales and that caused check-language-support to say that I now have a correct configuration but if it is, it's only in that konsole session. This problem also prevents konsole from showing unicode characters and I cannot use dead keys or enter any 'international character' such as ñ or ç (those work on other applications such as Firefox, that I'm using to post this question).

So the question is: How do I set up a global locale for the computer?

This is not a bug report, I will probably reinstall my computer eventually if I can't fix it. But I really want to know how I can perform this REALLY basic task.

Thank you.

$ check-language-support
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "en:es:en",
        LC_ALL = (unset),
        LC_PAPER = "en_ES.UTF-8",
        LC_ADDRESS = "en_ES.UTF-8",
        LC_MONETARY = "en_ES.UTF-8",
        LC_NUMERIC = "en_ES.UTF-8",
        LC_TELEPHONE = "en_ES.UTF-8",
        LC_IDENTIFICATION = "en_ES.UTF-8",
        LC_MEASUREMENT = "en_ES.UTF-8",
        LC_TIME = "en_ES.UTF-8",
        LC_NAME = "en_ES.UTF-8",
        LANG = "en_ES.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
hunspell-en-ca libreoffice-help-en-gb libreoffice-l10n-en-gb libreoffice-l10n-en-za mythes-en-au wspanish

$ cat /etc/default/locale
LANG="en_US.UTF-8"
LC_NUMERIC="es_ES.UTF-8"
LC_TIME="es_ES.UTF-8"
LC_MONETARY="es_ES.UTF-8"
LC_PAPER="es_ES.UTF-8"
LC_NAME="es_ES.UTF-8"
LC_ADDRESS="es_ES.UTF-8"
LC_TELEPHONE="es_ES.UTF-8"
LC_MEASUREMENT="es_ES.UTF-8"
LC_IDENTIFICATION="es_ES.UTF-8"


$ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_ES.UTF-8
LANGUAGE=en:es:en
LC_CTYPE="en_ES.UTF-8"
LC_NUMERIC=en_ES.UTF-8
LC_TIME=en_ES.UTF-8
LC_COLLATE="en_ES.UTF-8"
LC_MONETARY=en_ES.UTF-8
LC_MESSAGES="en_ES.UTF-8"
LC_PAPER=en_ES.UTF-8
LC_NAME=en_ES.UTF-8
LC_ADDRESS=en_ES.UTF-8
LC_TELEPHONE=en_ES.UTF-8
LC_MEASUREMENT=en_ES.UTF-8
LC_IDENTIFICATION=en_ES.UTF-8
LC_ALL=
$ update-locale
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "en:es:en",
        LC_ALL = (unset),
        LC_PAPER = "en_ES.UTF-8",
        LC_ADDRESS = "en_ES.UTF-8",
        LC_MONETARY = "en_ES.UTF-8",
        LC_NUMERIC = "en_ES.UTF-8",
        LC_TELEPHONE = "en_ES.UTF-8",
        LC_IDENTIFICATION = "en_ES.UTF-8",
        LC_MEASUREMENT = "en_ES.UTF-8",
        LC_TIME = "en_ES.UTF-8",
        LC_NAME = "en_ES.UTF-8",
        LANG = "en_ES.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

8 Answers 8

10

I've solved this problem following the steps below. I've been studying how locales work and the different configuration sets between some distributions (Debian Based originally).

I use Linux Mint as my primary system distribution and Debian as my system servers.

Despite the fact Ubuntu is derived from Debian, the locale settings are slightly different.

1) Verify which locales are installed and generated in your system:

sudo locale -a

2) remove undesired locales using the following command:

sudo localedef --delete-from-archive <YOUR DESIRED LOCALE HERE>

for example:

sudo localedef --delete-from-archive en_AG

The default configuration located in /etc/default/locale is overriden by the personal (local user only) settings generated by the System Language App. These settings are located in $HOME/.pam_environment ($HOME = The location of your home folder).

Empty this file and write the configurations you may need.

My .pam_environment file:

LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
LC_NUMERIC=pt_BR.UTF-8
LC_TIME=pt_BR.UTF-8
LC_MONETARY=pt_BR.UTF-8
LC_PAPER=pt_BR.UTF-8
LC_IDENTIFICATION=pt_BR.UTF-8
LC_NAME=pt_BR.UTF-8
LC_ADDRESS=pt_BR.UTF-8
LC_TELEPHONE=pt_BR.UTF-8
LC_MEASUREMENT=pt_BR.UTF-8
LC_CTYPE=pt_BR.UTF-8

The LANG variable sets the non configured LC_* to the value set configured there. For example:

If the system makes a lookup for the LC_TIME variable, and it is not set, it will use the LANG value as default for that variable (LC_TIME in this case).

My .pam_environment basically says: set almost all variables to pt_BR.UTF-8 and the system language to english.

I hope this information may be userful.

9

Bug is reported here: https://bugs.launchpad.net/ubuntu/+source/kde-runtime/+bug/1322968 - "Changing country leads to invalid locale"

Workarounds:

  1. Select country British English - not American English (and then language Spain)
  2. Or manually edit ~/.kde/env/setlocale.sh after having changed Country/Region & Language settings
0
2

Another solution is to alias English (Spain) to English (US):

echo en_ES.UTF-8 en_US.UTF-8 >> /etc/locale.aliases

1
  • Even if this is just a workaround, I think it's clever and I like it. It most likely works too :)
    – Calabacin
    Jun 8, 2017 at 9:23
1

You will want to use the update-locale command. Visit that page on how to use it. You basically run it (with sudo) with arguments setting the locale how you wish it to be. This "Modif[ies] global locale settings" to your requirements.

Edit 1: You may also look into locale-gen if the previous does not work for you.

2
  • Thank you. I already tried that. dpkg-reconfigure locales generated all possible combinations for english and spanish. It seems to call locale-gen for all installed languages combinations. I also called locale-gen for several locales just in case. The problem is that en_ES doesn't exist
    – Calabacin
    Jul 22, 2014 at 16:14
  • Very well, I will keep looking for solutions. I haven't seen a problem like this in a long time. Jul 22, 2014 at 16:59
1

Like Freddy Vulto commented in his answer, this is a known bug reported here: https://bugs.launchpad.net/ubuntu/+source/kde-runtime/+bug/1322968

Please take a look at it that bug report if you need to fix it manually. It can be fixed calling ~/.kde/env/setlocale.sh (possibly after modifying), among other possible fixes.

1

I managed to temporarily fix the issue by changing the system language from American English to British English as suggested above. I did it via the KDE System Settings > Locale > Languages dialog. Amusingly, it displayed an error message saying that replacing the current language was not permitted, but in practice it was since the new settings were applied when I hit the "apply" button, and restarted the machine.

0

I had same problem in my system: Kubuntu 16.04 LTS (kernel:4.4.0-31-generic(x86_64)). But I solved it in very simple way:

in "system settings" under "personalization" tab, click on "regional settings". choose "Formats" from right menu. In the left check "detailed settings" and change every detail such as Numbers or Time to your desired language and region.

(system settings > regional settings > formats > detailed settings)

I know it is elementary but can be useful for someone.

-3

Guys guys why are you going crazy?? All you need is to go to Search bar or Unity Lens (if Ubuntu) type "Language" you will find "Country/Region & Language" Application. In the "Country" Tab Choose your desired locale language.

If you want to keep current locale and change some other options like date format, or imperial to metric measurements, just use the other tabs! :)

This is available in Ubuntu distro 14.04 LTS and later.

1
  • 4
    Ubuntu has Unity by default. This is a KDE issue. Completely unrelated. Besides, changing the regional settings didn't fix the issue, as stated in op. Still thank you for taking your time to try to fix this issue.
    – Calabacin
    Feb 6, 2015 at 14:58

You must log in to answer this question.

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