Summary: | Changing the Regional Settings in System Settings does not change the LC_* vars in the shell (even after rebooting) | ||
---|---|---|---|
Product: | [Applications] systemsettings | Reporter: | jcrmatos |
Component: | kcm_regionandlang | Assignee: | Plasma Bugs List <plasma-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | akselmo, hanyoung, jcrmatos, nate |
Priority: | NOR | ||
Version: | 5.27.11 | ||
Target Milestone: | --- | ||
Platform: | Ubuntu | ||
OS: | Linux | ||
Latest Commit: | https://invent.kde.org/plasma/plasma-workspace/-/commit/fecb669d90835d7cc6855944ca842e150bcf77c3 | Version Fixed In: | 6.2.0 |
Sentry Crash Report: |
Description
jcrmatos
2024-08-05 15:05:45 UTC
> Change the Regional Settings in the System Settings
Did you only change the "Language" section or the other sections as well (like "Time" for example)
If you only changed "Language", then this is the expected behavior. "Language" only modify $LANG and $LANGUAGE.
If not, please paste the contents of ~/.config/plasma-localerc
(In reply to hanyoung from comment #1) No, I changed all the settings. After changing the defaults to what I want and rebooted, all seemed fine, but if I changed them to the defaults and reboot again, the ~/.config/plasma-localerc is changed (which is correct) but the bash LC_* vars aren't. Here are the contents of ~/.config/plasma-localerc after I changed the settings to what I want. These are correct: [Formats] LANG=en_US.UTF-8 LC_ADDRESS=C LC_MEASUREMENT=C LC_MONETARY=pt_PT.UTF-8 LC_NAME=C LC_NUMERIC=pt_PT.UTF-8 LC_PAPER=C LC_TELEPHONE=C LC_TIME=C And here are the LC_* bash vars (which are correct): LANG=en_US.UTF-8 LANGUAGE=en_US LC_CTYPE=pt_PT.UTF-8 LC_NUMERIC=pt_PT.UTF-8 LC_TIME=pt_PT.UTF-8 LC_COLLATE="en_US.UTF-8" LC_MONETARY=pt_PT.UTF-8 LC_MESSAGES="en_US.UTF-8" LC_PAPER=pt_PT.UTF-8 LC_NAME=pt_PT.UTF-8 LC_ADDRESS=pt_PT.UTF-8 LC_TELEPHONE=pt_PT.UTF-8 LC_MEASUREMENT=pt_PT.UTF-8 LC_IDENTIFICATION=pt_PT.UTF-8 LC_ALL= If I change the Regional Settings to the defaults and reboot again, the ~/.config/plasma-localerc changes to this (which is correct): [Formats] LANG=en_US.UTF-8 but the LC_* bash vars don't change. > > Change the Regional Settings in the System Settings > > Did you only change the "Language" section or the other sections as well > (like "Time" for example) > > If you only changed "Language", then this is the expected behavior. > "Language" only modify $LANG and $LANGUAGE. > > If not, please paste the contents of ~/.config/plasma-localerc I forgot to change the status. I can't reproduce the issue with current it master. Is this something that would have gotten fixed in Plasma 6, Han? > I can't reproduce the issue with current it master. Is this something that would have gotten fixed in Plasma 6, Han? I don't think so. > but the LC_* bash vars don't change. AFAIK, kde only loads ~/.config/plasma-localerc on start up. So if the config file is correct, but locale output isn't, high chance the env come from elsewhere (In reply to hanyoung from comment #5) > > I can't reproduce the issue with current it master. Is this something that would have gotten fixed in Plasma 6, Han? > > I don't think so. > > > but the LC_* bash vars don't change. > > AFAIK, kde only loads ~/.config/plasma-localerc on start up. So if the > config file is correct, but locale output isn't, high chance the env come > from elsewhere When changing the settings in the Regional Settings KDE changes ~/.config/plasma-localerc and the respective bash LC_* vars. Which is correct. But not when I select the defaults. That is the problem here. > But not when I select the defaults.
Is there any LC_* in ~/.config/plasma-localerc after clicking defaults?
(In reply to hanyoung from comment #7) > > But not when I select the defaults. > > Is there any LC_* in ~/.config/plasma-localerc after clicking defaults? No, only this [Formats] LANG=en_US.UTF-8 (In reply to jcrmatos from comment #8) > (In reply to hanyoung from comment #7) > > > But not when I select the defaults. > > > > Is there any LC_* in ~/.config/plasma-localerc after clicking defaults? > > No, only this > [Formats] > LANG=en_US.UTF-8 Then the incorrect bash LC_* vars aren't caused by systemsettings. You may have set them in other locations, maybe system wide settings? (In reply to hanyoung from comment #9) > (In reply to jcrmatos from comment #8) > > (In reply to hanyoung from comment #7) > > > > But not when I select the defaults. > > > > > > Is there any LC_* in ~/.config/plasma-localerc after clicking defaults? > > > > No, only this > > [Formats] > > LANG=en_US.UTF-8 > > Then the incorrect bash LC_* vars aren't caused by systemsettings. You may > have set them in other locations, maybe system wide settings? No, I haven't set them anywhere. I only used systemsettings to change them and they are updated by systemsettings when I select anything but the defaults. Only when I select the defaults they aren't updated. The clue may be exactly why when selecting the defaults the ~/.config/plasma-localerc doesn't receive the same lines as when I change them the settings from the defaults. Here is an example of what would be the "correct" defaults in ~/.config/plasma-localerc: [Formats] LANG=en_US.UTF-8 LC_ADDRESS=en_US.UTF-8 LC_MEASUREMENT=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_NAME=en_US.UTF-8 LC_NUMERIC=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_TELEPHONE=en_US.UTF-8 LC_TIME=en_US.UTF-8 which would correspond to the defaults shown in systemsettings. > Here is an example of what would be the "correct" defaults in ~/.config/plasma-localerc
If LC_* are not explicitly set, they just default to whatever $LANG is. That's exactly why "defaults" button remove them from plasma-localerc
(In reply to hanyoung from comment #11) > > Here is an example of what would be the "correct" defaults in ~/.config/plasma-localerc > > If LC_* are not explicitly set, they just default to whatever $LANG is. > That's exactly why "defaults" button remove them from plasma-localerc In that case the LC_* vars in bash and the locale command should also be cleared or updated to the same value as LANG (en_US.UTF-8) so that the systemsettings, the bash LC_* vars and the locale command all the synced. > In that case the LC_* vars in bash and the locale command should also be cleared or updated to the same value as LANG (en_US.UTF-8) so that the systemsettings, the bash LC_* vars and the locale command all the synced.
There is nothing to sync here. Plasma will set the env if they are in plasma-localerc. There is no other persistent settings plasma uses.
(In reply to hanyoung from comment #13) > > In that case the LC_* vars in bash and the locale command should also be cleared or updated to the same value as LANG (en_US.UTF-8) so that the systemsettings, the bash LC_* vars and the locale command all the synced. > > There is nothing to sync here. Plasma will set the env if they are in > plasma-localerc. There is no other persistent settings plasma uses. I'm sorry to repeat myself, but if plasma updates the bash LC_* vars and the locale command output when I change the settings, which is the correct behavior, but does not do the same when I select the defaults, I believe this isn't correct. It's behavior should always be the same, don't you think? > but does not do the same when I select the defaults
What do you think plasma should do in that case? Override system settings? How does plasma know what your idea of "default locale" is? Default means plasma doesn't set anything and inherit from system.
(In reply to hanyoung from comment #15) > > but does not do the same when I select the defaults > > What do you think plasma should do in that case? Override system settings? > How does plasma know what your idea of "default locale" is? Default means > plasma doesn't set anything and inherit from system. What I think it should do is exactly the same it does when I make any change from the defaults. When I make a change from the defaults it fills all the LC_*. This behavior works fine and syncs the plasma systemsettings with the LC_* bash vars and the locale output. But when I change to the defaults it removes all of them from the plasma-localerc and keeps only LANG. That is what seems to be the problem. Maybe if instead of clearing all and keeping only LANG it kept all LC_* and simply changed them to the same default as LANG (en_US.UTF-8) the sync could be achieved when selecting the defaults? > Maybe if instead of clearing all and keeping only LANG it kept all LC_* and simply changed them to the same default as LANG (en_US.UTF-8) the sync could be achieved when selecting the defaults?
That's not defaults though. Your "incorrect LC_*" came from other places. Maybe system wide, or from display server env config like xorg. Overriding config from somewhere else is not default.
(In reply to hanyoung from comment #17) > > Maybe if instead of clearing all and keeping only LANG it kept all LC_* and simply changed them to the same default as LANG (en_US.UTF-8) the sync could be achieved when selecting the defaults? > > That's not defaults though. Your "incorrect LC_*" came from other places. > Maybe system wide, or from display server env config like xorg. Overriding > config from somewhere else is not default. I just installed this system. It does not have any change to the default config except the selection of timezone and keyb layout on the installation. I showed how the behavior of systemsettings isn't the same when changing the defaults vs when setting to the defaults. In my opinion it should be the same in either action and if it was it would solve the lost sync between it and the LC_* bash vars and the locale output. As far as I understand, if you set default values in the KCM, it will pick whatever values the system has (this can be the defaults of your distro or something else). Is this what you mean? Also can you give us exact steps when testing this, so we can try to replicate it as close as possible? (In reply to Akseli Lahtinen from comment #19) > As far as I understand, if you set default values in the KCM, it will pick > whatever values the system has (this can be the defaults of your distro or > something else). > > Is this what you mean? Also can you give us exact steps when testing this, > so we can try to replicate it as close as possible? This issue has 2 parts. To make it easy for you to replicate, I created a new VM and made a clean install of kubuntu 24.04.1 desktop amd64 EFI. I live in Lisbon, Portugal, so that you understand why the installer assumes that during installation. The selections I had during installation were: Language: American English (pre-selected by the installer) Region: Europe (pre-selected by the installer) Zone: Lisbon (pre-selected by the installer) Numbers and dates locale: European Portuguese (Portugal) (pre-selected by the installer) Keyboard mode: Generic 105-key PC (pre-selected by the installer) Keyboard layout: Portuguese, Default Normal installation (pre-selected by the installer) Download and install updates following installation Erase Disk, swap to file, btfrs After the installation finished I checked these: Login page is in English (correct) and hour and date are shown in Portuguese (correct). Desktop shows pt (for the Portuguese keyboard, which is correct) and hour and date are in Portuguese format (correct). The lock screen shows hour and date in Portuguese (correct). Output of env | grep LANG LANGUAGE= LANG=en_US.UTF-8 Output of env | grep LC LC_ADDRESS=pt_PT.UTF-8 LC_NAME=pt_PT.UTF-8 LC_MONETARY=pt_PT.UTF-8 LC_PAPER=pt_PT.UTF-8 LC_IDENTIFICATION=pt_PT.UTF-8 LC_TELEPHONE=pt_PT.UTF-8 LC_MEASUREMENT=pt_PT.UTF-8 LC_CTYPE=pt_PT.UTF-8 LC_TIME=pt_PT.UTF-8 LC_NUMERIC=pt_PT.UTF-8 Output of cat /etc/locale.conf LANG=en_US.UTF-8 LC_ADDRESS=pt_PT.UTF-8 LC_IDENTIFICATION=pt_PT.UTF-8 LC_MEASUREMENT=pt_PT.UTF-8 LC_MONETARY=pt_PT.UTF-8 LC_NAME=pt_PT.UTF-8 LC_NUMERIC=pt_PT.UTF-8 LC_PAPER=pt_PT.UTF-8 LC_TELEPHONE=pt_PT.UTF-8 LC_TIME=pt_PT.UTF-8 It's not important for this issue, but note that LC_CTYPE is missing from /etc/locale.conf. 1st part of the issue is the following. If I go to System Settings\Regional Settings\Region & Language, it shows Language American English (correct), but all the other items are wrong (they are all in American English instead of Portuguese like the /etc/locale.conf and the env vars LC_*). To correct them I must install some necessary packages using the following commands sudo apt install $(check-language-support) sudo apt install hunspell hunspell-pt-br hunspell-pt-pt hyphen-pt-br hyphen-pt-pt language-pack-pt libreoffice-help-pt libreoffice-help-pt-br libreoffice-l10n-pt libreoffice-l10n-pt-br libreoffice-lightproof-pt-br mythes-pt-br mythes-pt-pt wbrazilian wportuguese and reboot. Next I modify all the wrong settings in System Settings\Regional Settings\Region & Language to european Portuguese (Portugal) pt_PT.UTF-8, and reboot. Now everything seems OK. If I go back to System Settings\Regional Settings\Region & Language all the settings are correct. The env vars LC_* and LANG and the /etc/locale.conf are all correct. Now the 2nd part of the issue. If I press the Defaults button, it changes all items to American English (correct). I press Apply and reboot. After rebooting the Login screen still shows the hour and date in Portuguese (incorrect). After logging in, the desktop shows the hour and date in Portuguese (incorrect). The env | grep LC command shows the same values as before (Portuguese), which are incorrect. They should all be en_US.UTF-8. Output of env | grep LANG LANGUAGE=en_US LANG=en_US.UTF-8 These are correct, but notice that before the LANGUAGE var was blank. I don't see this as a problem or important, but just wanted to highlight it. The /etc/locale.conf still remains with the old values (all Portuguese except for the LANG), which is incorrect. The lock screen also shows the hour and date in Portuguese, which is incorrect. So, summarizing: 1. The settings on the System Settings\Regional Settings\Region & Language after installation do not match the installation selections; 2. After changing the System Settings\Regional Settings\Region & Language to the Defaults, it doesn't update the Login screen, the desktop hour/date, the lock screen, the env vars LC_* or the /etc/locale.conf. In my opinion changing the System Settings\Regional Settings\Region & Language should update all of the above so that the system is in sync either on the GUI or the shell. I have print-screens that I can send you, if you need to. Thanks. Ah, so the problem is Kubuntu installer set the system-wide locale settings, but Plasma can only change user locale. When you install the system with Portuguese, the LC_* are set in /etc/locale.conf. But when you set language in Plasma, we override LANG and LANGUAGE in ~/.config/plasma-localerc. But we DO NOT change LC_* by default. Because LC_* should inherit LANG if not explicitly set. We didn't expect system-wide setting to explicitly set LC_* vars, because ideally they should be unset and inherit from LANG. I think an easy way to fix this problem would be to check LC_* vars when user is setting LANG in Plasma Language & Lang KCM. If the LC_* is explicitly set, and the setting is not coming from Plasma, we also override LC_* in ~/.config/plasma-localerc. (In reply to hanyoung from comment #21) > Ah, so the problem is Kubuntu installer set the system-wide locale settings, > but Plasma can only change user locale. When you install the system with > Portuguese, the LC_* are set in /etc/locale.conf. But when you set language > in Plasma, we override LANG and LANGUAGE in ~/.config/plasma-localerc. But > we DO NOT change LC_* by default. Because LC_* should inherit LANG if not > explicitly set. > > We didn't expect system-wide setting to explicitly set LC_* vars, because > ideally they should be unset and inherit from LANG. I think an easy way to > fix this problem would be to check LC_* vars when user is setting LANG in > Plasma Language & Lang KCM. > If the LC_* is explicitly set, and the setting is not coming from Plasma, we > also override LC_* in ~/.config/plasma-localerc. If it helps, the contents of ~/.config/plasma-localerc in the 3 stages are the following. 1. After installation, ~/.config/plasma-localerc has this content [Formats] LANG=en_US.UTF-8 2. After correcting all the options (except the system language that always remain American English) in System Settings\Regional Settings\Region & Language to Portuguese, ~/.config/plasma-localerc has this content [Formats] LANG=en_US.UTF-8 LC_ADDRESS=pt_PT.UTF-8 LC_MEASUREMENT=pt_PT.UTF-8 LC_MONETARY=pt_PT.UTF-8 LC_NAME=pt_PT.UTF-8 LC_NUMERIC=pt_PT.UTF-8 LC_PAPER=pt_PT.UTF-8 LC_TELEPHONE=pt_PT.UTF-8 LC_TIME=pt_PT.UTF-8 Please note that LC_IDENTIFICATION and LC_CTYPE are not present. Shouldn't they be? 3. After pressing the Defaults button and rebooting, ~/.config/plasma-localerc has this content [Formats] LANG=en_US.UTF-8 If I understood correctly your 2nd paragraph, that would solve only the GUI part of the 2nd part of the issue. It would still remain unsynced between the GUI and the shell. Am I wrong? And what would be a possible correction for the 1st part? A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/4739 Git commit 5a687105d02d3882accd80d251861f264be22c18 by Han Young. Committed on 30/09/2024 at 10:09. Pushed by hanyoung into branch 'master'. kcm_regionandlang: always set LC_* when changing language If the LC_* is not set with Plasma (~/.config/plasma-localerc), they inherit system-wide setting. However, we don't take system-wide setting into account when displaying LC_* vars. As the result, the UI may display incorrect results. Always set LC_* when changing language to avoid this issue. M +4 -0 kcms/region_language/kcmregionandlang.cpp M +12 -0 kcms/region_language/regionandlangsettings.cpp M +23 -0 kcms/region_language/regionandlangsettings.h https://invent.kde.org/plasma/plasma-workspace/-/commit/5a687105d02d3882accd80d251861f264be22c18 Git commit fecb669d90835d7cc6855944ca842e150bcf77c3 by Nate Graham. Committed on 30/09/2024 at 13:16. Pushed by ngraham into branch 'Plasma/6.2'. kcm_regionandlang: always set LC_* when changing language If the LC_* is not set with Plasma (~/.config/plasma-localerc), they inherit system-wide setting. However, we don't take system-wide setting into account when displaying LC_* vars. As the result, the UI may display incorrect results. Always set LC_* when changing language to avoid this issue. (cherry picked from commit 5a687105d02d3882accd80d251861f264be22c18) Co-authored-by: Han Young <hanyoung@protonmail.com> M +4 -0 kcms/region_language/kcmregionandlang.cpp M +12 -0 kcms/region_language/regionandlangsettings.cpp M +23 -0 kcms/region_language/regionandlangsettings.h https://invent.kde.org/plasma/plasma-workspace/-/commit/fecb669d90835d7cc6855944ca842e150bcf77c3 |