2

I want to change the language of my computer. I tried doing this with sudo dpkg-reconfigure locales. this changed the LANG environment variable in /etc/default/locale but none of the LC environment variables changed.

/etc/default/locale says # File generated by update-locale so I presume there is some correct way of generating this file so that the LC variables are as desired.

Oddly, after changing the LC_ variables by hand and sourcing /etc/default/locale when I rerun update-locale the LC variables inside /etc/default/locale keep their value rather than resetting to the old one. These also remain the same after a sudo dpkg-reconfigure locales. So may you are meant to just change these variables by hand and thereafter all the tools will keep them the same?

1 Answer 1

3

sudo dpkg-reconfigure locales is for controlling the total set of locales selectable by regular users, and rebuilding the locale data for them. See localectl list-locales for a list of locales that are actually available for immediate use on your system. Some distributions may require an appropriate language support package to be installed before the locales for that language can be generated.

update-locale can change the locale variables, but you'll need to specify the change you want on the command line. Just running update-locale without any parameters will do nothing.

The example given in the man page is:

update-locale LANG=en_CA.UTF-8 LANGUAGE 

which sets LANG to en_CA.UTF-8 and removes any existing definitions for LANGUAGE.

update-locale is really meant to be used by package installation/removal scripts, not by users or the system administrator... but you certainly can use it if you prefer it.

localectl is probably the current "expected" administrative interface for system-wide locale settings. When invoked without parameters, it will display the current settings; to make changes, you'll need to use the syntax localectl set-locale <VARIABLE=value>.

Also, since locale settings are fundamentally just environment variables, changing them will usually require a logout and a new login for full effect in user sessions. For system daemons to get the new system locale, you'll either need to restart the daemon(s) in question, or simply reboot the system to ensure the new default locale is fully in effect with all processes.

Some desktop environments may be able to change locale settings dynamically by communicating the change to the main process of the GUI session and having it re-start all the other desktop environment elements with a new set of environment variables in effect... but logging out and back in ensures that all programs, including those that are not native to the desktop environment used, will get the new setting.

The values in /etc/default/locale are just system-wide defaults: if any user overrides them in their personal login scripts, then that user's sessions will use a non-default locale until the override is removed (if the data for that locale is made available by installing the required language support package and/or using dpkg-reconfigure locales).

2
  • Hmm... feels a bit like a mess. I had a play with localectl. It looks like it will remove LC_ locale settings if they are the same as LANG - but leave them intact if they are not specified on the run. This suggests that the "reliable" way of changing language is something like localectl set-locale LANG=da_DK.UTF-8 LC_NUMERIC=C LC_TIME="da_DK.UTF-8" LC_MONETARY="da_DK.UTF-8" LC_PAPER="da_DK.UTF-8" LC_NAME="da_DK.UTF-8" LC_ADDRESS="da_DK.UTF-8" LC_TELEPHONE="da_DK.UTF-8" LC_MEASUREMENT="da_DK.UTF-8" LC_IDENTIFICATION="da_DK.UTF-8" which isn't that nice. I feel like I should edit by hand! Commented May 27 at 18:06
  • Perhaps update-locale LANG=da_DK.UTF-8 LC_NUMERIC=C LC_TIME LC_MONETARY LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION seems like the way to go... Commented May 27 at 18:10

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.