Hi! I have created another user on my system and would like to set his locale to another language (slovak - sk_SK.utf8 in my case). I followed the guide on archwiki - created locale.conf in the user’s .config directory. Set it to:
System Locale: LANG=en_US.UTF-8
LC_NUMERIC=sk_SK.UTF-8
LC_TIME=sk_SK.UTF-8
LC_MONETARY=sk_SK.UTF-8
LC_PAPER=sk_SK.UTF-8
LC_NAME=sk_SK.UTF-8
LC_ADDRESS=sk_SK.UTF-8
LC_TELEPHONE=sk_SK.UTF-8
LC_MEASUREMENT=sk_SK.UTF-8
LC_IDENTIFICATION=sk_SK.UTF-8
VC Keymap: us
X11 Layout: us
the output of locale -a is:
C
C.utf8
en_US.utf8
POSIX
sk_SK.utf8
so the locale should be installed. I am running xfce4, default install. But the locale just isn’t set when I log in via lightdm to the user. I also tried moving the locale.conf directly to the user’s home directory, but that doesn’t work. When I change the system locale in /etc/locale.conf to slovak, the locale is set, but for all users… Any ideas why the locale isn’t set for the user?
Welcome to the forum @dan1 !
I inserted your 10 lines into .bashrc of a second user named s.
(adduser was installed plus added s to the same groups as my 1st testuser in /etc/group)
uncommented sk_SK.utf-8 line in /etc/locale.gen
ran locale-gen as root
and if you want Slovak UI follow this guide
My orginal test user is still untouched.
You have to use the next (paragraph) method, (titled Make locale changes immediate) to achieve what you want.
In short, you have to add code in a login script (for LightDM, use .profile, or .xprofile), which will unset LANG and then source again /etc/profile.d/locale.sh .
Here is some example code snippet:
# Confirm local locale/LANG
LocalLocaleConf="${XDG_CONFIG_HOME}/locale.conf"
if [ -f "$LocalLocaleConf" ]; then
UserLang=$(grep "^LANG=" "$LocalLocaleConf" | cut -d= -f2 2>/dev/null)
if [ "${UserLang}" != "$LANG" ]; then
echo "Resetting locale language"
unset LANG
source /etc/profile.d/locale.sh
fi
else
echo "LANG=${LANG:-C}" >> "$LocalLocaleConf"
fi
If all variables use the same locale, you may use only the LANG variable.
Explanation is described in the Note.
The LANG variable has to be unset first, otherwise locale.sh will not update the values from locale.conf . Only new and changed variables will be updated; variables removed from locale.conf will still be set in the session.
Since Linux has already sourced the system script on system start, LANG has a value (from /etc/locale.conf) and needs to get unset first before it gets a new (local session/user) value.