Locale is not correctly applied

I tried changing locale from English to Italian by doing as stated in the docs

$ localectl set-locale LANG=it_IT.utf-8

After that, the status matches correctly the language and encoding I set:

$ $ localectl status 
   System Locale: LANG=it_IT.utf-8
       VC Keymap: it2
      X11 Layout: it,gb
     X11 Variant: ,

But when I run the locale command I do not get the UTF-8 variant of the language:

$ locale
LANG=it_IT
LC_CTYPE="it_IT"
LC_NUMERIC="it_IT"
LC_TIME="it_IT"
LC_COLLATE="it_IT"
LC_MONETARY="it_IT"
LC_MESSAGES="it_IT"
LC_PAPER="it_IT"
LC_NAME="it_IT"
LC_ADDRESS="it_IT"
LC_TELEPHONE="it_IT"
LC_MEASUREMENT="it_IT"
LC_IDENTIFICATION="it_IT"
LC_ALL=

In fact terminal applications don’t display characters correctly, for example dnf:

$ sudo dnf install gcc
Ultima verifica della scadenza dei metadati: 0:53:56 fa il dom 19 feb 2023, 15:10:02.
Il pacchetto gcc-12.2.1-4.fc37.x86_64 ďż˝ giďż˝ installato.
Dipendenze risolte.
Nessuna operazione da compiere.
Fatto!

How can I fix this?

sudo dnf install glibc-langpack-it
sudo localectl set-locale it_IT.UTF-8
busctl call org.freedesktop.Accounts \
    /org/freedesktop/Accounts/User${UID} \
    org.freedesktop.Accounts.User \
    SetLanguage s it_IT.UTF-8

You may need to relogin to apply changes.

1 Like

Still no difference unfortunately, the glibc-langpack I had already installed, I don’t understand the busctl part, could you explain?

The Fedora Workstation uses /var/lib/AccountsService/users/${USER} to store user session locale to and busctl can utilize the D-Bus API to edit that session config.

What is your display manager and session type?

loginctl session-status

I see, thanks for the explanation!

Here’s the output, I use GDM and KDE Plasma Wayland:

$ loginctl session-status
1 - <username> (1001)
           Since: Sun 2023-02-19 17:23:11 CET; 52min ago
          Leader: 1325 (gdm-session-wor)
            Seat: seat0; vc2
             TTY: tty2
         Service: gdm-autologin; type wayland; class user
           State: active
            Unit: session-1.scope
                  |-1325 "gdm-session-worker [pam/gdm-autologin]"
                  |-1347 /usr/bin/gnome-keyring-daemon --daemonize --login
                  |-1351 /usr/libexec/gdm-wayland-session --register-session "/usr/libexec/plasma-dbus-run-session-if-needed /usr/bin/startplasma-wayland"
                  `-1356 /usr/bin/startplasma-wayland

feb 19 17:23:11 fedora systemd[1]: Started session-1.scope - Session 1 of User <username>.
feb 19 17:23:11 fedora gdm-autologin][1325]: pam_unix(gdm-autologin:session): session opened for user <username>(uid=1001) by (uid=0)
feb 19 17:23:11 fedora gdm-autologin][1325]: gkr-pam: gnome-keyring-daemon started properly

I think you just made a typing error:

Instead of localectl set-locale LANG=it_IT.utf-8

try this:

localectl set-locale LANG=it_IT.UTF-8

1 Like

Hi,
the additional language package “gb” does not exist in my opinion.
So something has already gone wrong upfront.

As an example I have this in the file

[org.freedesktop.DisplayManager.AccountsService]
BackgroundFile='/usr/share/backgrounds/images/default.png'

[User]
Language=en_US.utf8
Session=
XSession=xfce
Icon=/home/vek/.face
SystemAccount=false

This gives a per user settings of Language to override the setting found in locale.conf.

The “gb” code is the code for the British keyboard.

No,

#gd_GB.UTF-8 UTF-8 

I’m currently using Arch and there have to be decompressed locales.
See here to check:

nano /etc/locale.gen

The keyboard code is not the same as the language code. Tne language code for United Kingdom is “en_GB.utf-8”. The keyboard layout code is independent from the choice of language code.

I think you found the right reason, I now did :

$ localectl set-locale LANG=it_IT.UTF-8

I feel like a fool, because I could have just tabbed to get the right text, but the thing that I don’t understand is why it didn’t seem to work at first.
I reran that with sudo, I deleted the .config/plasma-localercfile and logged out, when I logged back in locale still showed the same thing as before, then I figured I’d try changing to a completely different language to see what would happen, I put en_GB.UTF-8 (with sudo), removed that plasma config file and rebooted, now the it_IT-UTF-8 was finally applied properly!
But that’s not what I expected to happen, theoretically I should have got English instead, I don’t know what I’m doing wrong/misunderstanding

Btw, I have to thank you for getting me this far!

1 Like

I must correct myself here, I just changed the language to British English in the Plasma settings and logged out, now everything is working as expected:

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

[Translations]
LANGUAGE=en_GB:it_IT

$ locale
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=

$ localectl status 
   System Locale: LANG=en_GB.UTF-8
       VC Keymap: it2
      X11 Layout: it,gb
     X11 Variant: ,

Lastly, checking back through my command history I found out that the equal solution given by @vgaetera should have been effective of course, it’s just that I’d never deleted the .config/plasma-localerc after doing the change until I tried again after my mistake was pointed out by @ilikelinux and it occurred to me that was a required step when working in Plasma.

Thanks everyone for the help!

1 Like