5

On my Ubuntu 20.04LTS system, whenever I run locale:

$ locale
...
LC_MESSAGES=C
...

In spite of my /etc/default/locale/:

$ cat /etc/default/locale
#  File generated by update-locale
LANG="en_US.UTF-8"
...
LC_MESSAGES=en_US.UTF-8

Why is LC_MESSAGES "C" when I'm checking it via locale?

2
  • Not sure. Working here on 20.04 and 22.04 both. Have you fully updated your system? Is your clock correctly set? Is the Date correct?
    – anon
    Commented Sep 22, 2022 at 14:01
  • It's still on 20.04 as stated. But I think it's related to something else, so upgrade won't solve this. Yes, clock, date are both correct (synced via NTP).
    – Daniel
    Commented Sep 22, 2022 at 14:02

1 Answer 1

1

"Default" implies that there are other, higher-priority settings which locale respects first.

The locale is not read directly from /etc/default – it is only read from environment variables $LC_MESSAGES and such, while the file you're editing is only used to set up those environment variables at login time. What you see in env|grep ^LC is more or less what will be printed by locale.

Usually the file is read very early during the login process (via PAM), so the resulting environment variables can be overridden from various other sources. For example, you might've set LC_MESSAGES manually, or your ~/.bashrc or ~/.profile may be exporting different values, or you logged in through GNOME and it retrieved the per-user settings from GSettings1. For SSH connections, if the client has "SendEnv" enabled, it might be sending the client-side $LC_* variables to the server which will override whatever PAM has set up.

Finally, if the $LC_ALL environment variable happens to be set (regardless of where it comes from), it will have priority over all other $LC_* settings.


1 dconf-editor org.gnome.system.locale

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .