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

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

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.


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

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