[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Looking for help with locale configuration



On Thu 14 Jan 2021 at 19:06:34 (+0000), Rasmus MK wrote:
> 
> I'm looking for help in understanding how locales work and how to configure my 
> system running Debian Testing.
> 
> During the Debian installation (graphical) I configured my locale to be 
> "en_SE.UTF-8".
> Recently a python script crashed with the error message "unsupported locale 
> setting" after trying to set LC_ALL to an empty string and I cannot get it to 
> work with the en_SE.UTF-8 locale.
> 
> I use KDE. If I look in Settings -> Regional Settings -> Format it says 
> en_SE.UTF-8 (no adjustments). 
> 
> The output of `locale` is:
> 
> 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_SE.UTF-8
> LANGUAGE=
> LC_CTYPE="en_SE.UTF-8"
> LC_NUMERIC="en_SE.UTF-8"
> LC_TIME="en_SE.UTF-8"
> LC_COLLATE="en_SE.UTF-8"
> LC_MONETARY="en_SE.UTF-8"
> LC_MESSAGES="en_SE.UTF-8"
> LC_PAPER="en_SE.UTF-8"
> LC_NAME="en_SE.UTF-8"
> LC_ADDRESS="en_SE.UTF-8"
> LC_TELEPHONE="en_SE.UTF-8"
> LC_MEASUREMENT="en_SE.UTF-8"
> LC_IDENTIFICATION="en_SE.UTF-8"
> LC_ALL=

Those error messages probably indicate that you (accidentally or
otherwise) unset all the locales. It looks as if you might have done
this by selecting a locale that's unavailable on your system. (I don't
know which configuration method you're using.)

The list of locales supported should be in /usr/share/i18n/SUPPORTED
The locales themselves are defined in /usr/share/i18n/locales/*, so
check the ones you want are defined. (My buster has sv_SE.UTF-8,
for example, but not en_SE.UTF-8.)

> A few observations:
> 
> - `dpkg-reconfigure locales` does not let me choose the en_SE.UTF-8 locale. 
> The closest matches are sv_SE.UTF-8 and en_US.UTF-8. /etc/locales.gen also 
> lacks en_SE.UTF-8.

That seems to confirm the above.

> - If I set my locale to sv_SE.UTF-8 or en_US.UTF-8 the python script works 
> fine. Also, the "locale: ..." error messages (?) from the output of `locale -a` 
> disappears.

That should be the case: they're both existing locales.

> - If I use `localectl` to set the locale to something else than is configured 
> in KDE this is not picked up. KDE and `locale` will show different values.

Already covered, I think. I know nothing about KDE.

> I want to have the exact locale settings of en_SE.UTF-8. If possible I would 
> also prefer to avoid being dependant on my desktop environment to configure 
> this (i.e. use localectl or similar). Obviously I also want the Python script 
> to work.

Has anybody written that locale? You could write your own, as there's
any number of examples in the directories above, and much of the task
is just adding copy this and copy that. You would put your own file
into /usr/local/share/i18n/locales/xx_XX.UTF-8 and its name into the
file /usr/local/share/i18n/SUPPORTED. Then   dpkg-reconfigure locales
would offer it amongst the alternatives. (NB Be aware that locales are
not added to the system cumulatively: you have to specify all you want
each time you configure them.)

> I feel like there is something I don't understand. Any advice or explanation 
> would be deeply appreciated!

On Thu 14 Jan 2021 at 20:16:49 (+0000), Rasmus MK wrote:
[…]
> No, that is not the problem, sorry for being unclear. It has nothing to do 
> with Python. The problem is that the script crashes (when setting LC_ALL) when 
> run with the locale set to en_SV.UTF-8.

I don't think the English-speaking community in El Salvador is large
enough to have come up with en_SV.UTF-8. There is an es_SV.UTF-8
locale, as the majority there speak Spanish.

> If I use sv_SE.UTF-8 or en_US.UTF-8 it 
> works fine. What could be the cause for this?

Those are the standard locales for Swedes in Sweden and Americans
in the US, and are configurable.

How much changes for you when you run your software using these
two locales? Which one suits your software the best? You might find
that you don't have to set them all to the same value, eg LC_CTYPE
for changing letter case, and LC_MESSAGES for error messages etc.

Cheers,
David.


Reply to: