Bug 461949 - Region & Language sets language to non-UTF-8 locale
Summary: Region & Language sets language to non-UTF-8 locale
Status: RESOLVED FIXED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_regionandlang (show other bugs)
Version: 5.26.3
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
: 479542 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-11-17 13:03 UTC by Gurenko Alex
Modified: 2024-01-09 11:28 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.27
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gurenko Alex 2022-11-17 13:03:56 UTC
SUMMARY

If you set Language in Region & Language to American English or British English for example it sets locale to "en_US" or "en_GB" respectively, Deutsch to simply "de". Other fields are set to correct settings if modified.

STEPS TO REPRODUCE
1. Open Region & Language
2. Set language to something else "American English"
3. cat ~/.config/plasma-localerc

OBSERVED RESULT

$ cat .config/plasma-localerc
[Formats]
LANG=en_US

[Translations]
LANGUAGE=en_US

EXPECTED RESULT

cat .config/plasma-localerc
[Formats]
LANG=en_US.UTF-8

[Translations]
LANGUAGE=en_US.UTF-8


SOFTWARE/OS VERSIONS

Operating System: Fedora Linux 37
KDE Plasma Version: 5.26.3
KDE Frameworks Version: 5.100.0
Qt Version: 5.15.7
Kernel Version: 6.0.9-300.fc37.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 24 × AMD Ryzen 9 5900X 12-Core Processor
Memory: 31.3 GiB of RAM
Graphics Processor: AMD Radeon RX 6800 XT
Manufacturer: Micro-Star International Co., Ltd.
Product Name: MS-7C84
System Version: 1.0

ADDITIONAL INFORMATION

If other fields are modified, then it sets other fields correctly:

$ cat .config/plasma-localerc
[Formats]
LANG=en_US
LC_ADDRESS=en_DE.UTF-8
LC_MEASUREMENT=en_DE.UTF-8
LC_MONETARY=en_DE.UTF-8
LC_NAME=en_DE.UTF-8
LC_NUMERIC=en_DE.UTF-8
LC_PAGE=en_DE.UTF-8
LC_TELEPHONE=en_DE.UTF-8
LC_TIME=en_DE.UTF-8

[Translations]
LANGUAGE=en_US
Comment 1 Gurenko Alex 2022-11-17 13:11:27 UTC
Okay, for some reasons after reboot some "en_DE.UTF-8" got changed to "C.UTF-8" and if I pick "C" it sets it to "C" and not "C.UTF-8"
Comment 2 hanyoung 2022-11-17 13:20:40 UTC
(In reply to Gurenko Alex from comment #1)
> Okay, for some reasons after reboot some "en_DE.UTF-8" got changed to
> "C.UTF-8" and if I pick "C" it sets it to "C" and not "C.UTF-8"

We don't magically change config files.
Comment 3 Gurenko Alex 2022-11-17 13:26:38 UTC
(In reply to hanyoung from comment #2)
> (In reply to Gurenko Alex from comment #1)
> > Okay, for some reasons after reboot some "en_DE.UTF-8" got changed to
> > "C.UTF-8" and if I pick "C" it sets it to "C" and not "C.UTF-8"
> 
> We don't magically change config files.

Okay, my mistake, lets put it this way, following config:

$ cat .config/plasma-localerc
[Formats]
LANG=en_US.UTF-8
LC_ADDRESS=C.UTF-8
LC_MEASUREMENT=C.UTF-8
LC_MONETARY=C.UTF-8
LC_NAME=C.UTF-8
LC_NUMERIC=C.UTF-8
LC_PAGE=C.UTF-8
LC_TELEPHONE=C.UTF-8
LC_TIME=C.UTF-8

[Translations]
LANGUAGE=en_US.UTF-8

results in a following locale settings after reboot:

$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=C.UTF-8
LC_TIME=C.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=C.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT=C.UTF-8
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
Comment 4 Nate Graham 2022-11-29 19:38:52 UTC
Can reproduce the originally-reported issue of the non-UTF8 versions of languages being specified in cat ~/.config/plasma-localerc.
Comment 5 hanyoung 2022-12-01 14:32:05 UTC
what is the result of `ls /usr/share/i18n/locales` ?
Comment 6 Gurenko Alex 2022-12-01 15:59:39 UTC
(In reply to hanyoung from comment #5)
> what is the result of `ls /usr/share/i18n/locales` ?

It's empty for me
Comment 7 hanyoung 2022-12-01 17:32:56 UTC
(In reply to Gurenko Alex from comment #6)
> (In reply to hanyoung from comment #5)
> > what is the result of `ls /usr/share/i18n/locales` ?
> 
> It's empty for me

I know the cause, we use contents of this directory to map language code to glibc locale. If the directory is empty, the language code is passed through, no UTF-8 appended.
Comment 8 Bug Janitor Service 2022-12-03 08:32:34 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2397
Comment 9 Nate Graham 2022-12-26 17:05:32 UTC
Git commit 85ffb10a44c7f8ee0169033af350a740c2b7e0aa by Nate Graham, on behalf of Han Young.
Committed on 26/12/2022 at 17:05.
Pushed by ngraham into branch 'master'.

kcms/region_language: find available locales in localectl
FIXED-IN: 5.27

Not an ideal fix, but a fix without rewriting the entire language selection page.

M  +46   -3    kcms/region_language/kcmregionandlang.cpp
M  +10   -2    kcms/region_language/kcmregionandlang.h
M  +11   -8    kcms/region_language/languagelistmodel.cpp
M  +6    -5    kcms/region_language/languagelistmodel.h
M  +1    -1    kcms/region_language/package/contents/ui/AdvancedLanguageSelectPage.qml
M  +13   -0    kcms/region_language/package/contents/ui/main.qml

https://invent.kde.org/plasma/plasma-workspace/commit/85ffb10a44c7f8ee0169033af350a740c2b7e0aa
Comment 10 Harald Sitter 2024-01-09 11:28:35 UTC
*** Bug 479542 has been marked as a duplicate of this bug. ***