How to change/fix system's locale when you setup in a language not official in your country?

41,724

Solution 1

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

Solution 2

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.

Solution 3

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

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

Solution 4

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.

Solution 5

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.

Share:
41,724

Related videos on Youtube

Nell
Author by

Nell

Updated on September 18, 2022

Comments

  • Nell
    Nell over 1 year

    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").
    
  • Nell
    Nell almost 10 years
    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
  • AlwaysTalkingAboutMyDog
    AlwaysTalkingAboutMyDog almost 10 years
    Very well, I will keep looking for solutions. I haven't seen a problem like this in a long time.
  • Nell
    Nell over 9 years
    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.
  • Nell
    Nell almost 7 years
    Even if this is just a workaround, I think it's clever and I like it. It most likely works too :)