You are not logged in.

#1 2019-07-05 08:31:45

CK_Jazz
Member
Registered: 2016-09-26
Posts: 14

Overriding system locale per user session - not changing language

I followed the instructions for Overriding system locale per user session but I am not able to get the language changed for a specific user.

Here are my exact steps and output.

$ locale -a
C
POSIX
en_US
en_US.iso88591

I created ~/.config/locale.conf

$ cat .config/locale.conf
LANG=nl_NL.utf-8

Followed by

$ unset LANG
$ source /etc/profile.d/locale.sh

Finally

$ locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
POSIX
en_US
en_US.iso88591

I've even rebooted the system but the language doesn't change for the specific user,

Can someone point out where I am going wrong?

Thanks

Offline

#2 2019-07-05 08:36:39

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,209

Re: Overriding system locale per user session - not changing language

You have to generate the locale first in any case. locale -a shows you which locales you have theorethically available and generated (afaik this has to be done system wide regardless, look at the generating section), use just locale to find out which values are set to which variable.

Last edited by V1del (2019-07-05 08:39:39)

Offline

#3 2019-07-06 08:26:00

CK_Jazz
Member
Registered: 2016-09-26
Posts: 14

Re: Overriding system locale per user session - not changing language

I thought that I generated the locale when I set it up the first time.

So I would have to run locale-gen again before doing anything else?

Offline

#4 2019-07-06 08:35:11

Fixxer
Member
From: Poland
Registered: 2011-08-29
Posts: 232

Re: Overriding system locale per user session - not changing language

These are all generated and "active" localisations - listed by 'locale -a':

$ locale -a
C
POSIX
en_US
en_US.iso88591

There is no nl_NL listed here. If you want to use any locale you should generate if first. Uncomment suitable line in /etc/locale.gen and run command:

locale-gen

After it locale nl_NL will appear after 'locale -a'. Then you can alternate some variable like LANG=, etc., as written on Wiki:

by creating or editing ~/.config/locale.conf

Offline

#5 2019-07-09 12:41:45

CK_Jazz
Member
Registered: 2016-09-26
Posts: 14

Re: Overriding system locale per user session - not changing language

Thank you. I see where I went wrong with the Wiki - not reading the whole thing through to the point I need to reference.

$ locale -a
C
POSIX
en_US
en_US.iso88591
nl_NL.utf8

I created a new user with a ~/.config/locale.conf file

$ cat locale.conf
LANG=nl_NL.utf8

When I log in with the new user using MATE, everything is still in English. Even after rebooting the system, everything is still in English.

I'm scratching my head on this one.

Offline

#6 2019-07-09 16:10:03

Fixxer
Member
From: Poland
Registered: 2011-08-29
Posts: 232

Re: Overriding system locale per user session - not changing language

Check if you have any language settings in "Mate Control Center".

Offline

#7 2019-07-09 18:04:40

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,834

Re: Overriding system locale per user session - not changing language

Also the outputs of "localectl" and "locale" (no "-a")

Online

#8 2019-07-09 23:23:51

CK_Jazz
Member
Registered: 2016-09-26
Posts: 14

Re: Overriding system locale per user session - not changing language

Fixxer wrote:

Check if you have any language settings in "Mate Control Center".

I didn't see any language settings in Mate Control Center.

seth wrote:

Also the outputs of "localectl" and "locale" (no "-a")

$ cat .config/locale.conf 
LANG=nl_NL.utf8

$ localectl
System Locale: LANG=C
VC Keymap: n/a
X11 Layout: n/a

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

Offline

#9 2019-07-10 06:13:51

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,834

Re: Overriding system locale per user session - not changing language

I'd say you've no system locale configured and the local locale.conf isn't interpreted by whatever means the session is started.
This is supposed to be done by  /etc/profile.d/locale.sh

pacman -Qikk filesystem 2>&1 | grep profile

If that's clean, log into a console session (boot the multi-user.target and log in as you user) and check the locales there. You can also just start another "bash --login" shell (what should source /etc/profile)

Online

#10 2019-07-11 01:42:34

CK_Jazz
Member
Registered: 2016-09-26
Posts: 14

Re: Overriding system locale per user session - not changing language

pacman -Qikk filesystem 2>&1 | grep profile

That returns nothing.

Here is what my /etc/profile.d/locale.sh is showing

]$ cat /etc/profile.d/locale.sh
#!/bin/sh

# load locale.conf in XDG paths.
# /etc/locale.conf loads and overrides by kernel command line is done by systemd
# But we override it here, see FS#56688
if [ -z "$LANG" ]; then
  if [ -n "$XDG_CONFIG_HOME" ] && [ -r "$XDG_CONFIG_HOME/locale.conf" ]; then
    . "$XDG_CONFIG_HOME/locale.conf"
  elif [ -n "$HOME" ] && [ -r "$HOME/.config/locale.conf" ]; then
    . "$HOME/.config/locale.conf"
  elif [ -r /etc/locale.conf ]; then
    . /etc/locale.conf
  fi
fi

# define default LANG to C if not already defined
LANG=${LANG:-C}

# export all locale (7) variables when they exist
export LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \
       LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT \
       LC_IDENTIFICATION

Offline

#11 2019-07-11 06:17:47

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,834

Re: Overriding system locale per user session - not changing language

seth also wrote:

If that's clean, log into a console session (boot the multi-user.target and log in as you user) and check the locales there. You can also just start another "bash --login" shell (what should source /etc/profile)

It would seem however you start the session does not source /etc/profile - what means we probably should look at your DM, being…?

Online

#12 2019-07-11 16:42:02

CK_Jazz
Member
Registered: 2016-09-26
Posts: 14

Re: Overriding system locale per user session - not changing language

I am using xrdp to remote into the desktop environment.

Here is my .xinitrc

$ cat .xinitrc
#!/bin/bash
#
# ~/.xinitrc
#
# Executed by startx (run your windows manager from here)

if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/* ; do
     [ -x "$f" ] && . "$f"
  done
  unset f
fi

exec mate-session

Offline

#13 2019-07-11 19:12:04

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,834

Re: Overriding system locale per user session - not changing language

So you're using startx to run this? Or xinit?
Out of an interactive shell or do you kinda autologin/autorun it? (guessing because of xrdp)

Also (the d'ohh moment ;-)
Is the ~/.config/locale.conf on the remote or the local system?

Online

#14 2019-07-11 19:41:21

CK_Jazz
Member
Registered: 2016-09-26
Posts: 14

Re: Overriding system locale per user session - not changing language

I'm using Windows 7 to remote into Arch, so everything is going from the ~/.xinitrc file to start the desktop manager.

Everything is on the remote system that will later be replacing Windows 7 completely.

Offline

#15 2019-07-11 19:43:22

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,834

Re: Overriding system locale per user session - not changing language

seth wrote:

So you're using startx to run this? Or xinit?
Out of an interactive shell or do you kinda autologin/autorun it? (guessing because of xrdp)

"Desktop manager" doesn't sound like as if xinitrc was relevant at all, afaik only xdm uses xinitrc.

Online

#16 2019-07-12 08:43:23

CK_Jazz
Member
Registered: 2016-09-26
Posts: 14

Re: Overriding system locale per user session - not changing language

In the .xinitrc file, if I change

exec mate-session

with

exec startxfce4

it will load XFCE instead of MATE.

Of course that is if I am using xrpd. Locally, it uses LightDM but I do not have direct access at the moment to test the changes in person.

Offline

#17 2019-07-12 11:33:25

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,834

Re: Overriding system locale per user session - not changing language

So xrdp starts the session - and probably does nowhere source /etc/profile
add

. /etc/profile

at the top of your xinitrc. Idk. whether xrdp allows you to manipulate its shell loading process.
Remove it later on to avoid double sourcing of /etc/profile

Online

#18 2019-08-14 15:27:28

CK_Jazz
Member
Registered: 2016-09-26
Posts: 14

Re: Overriding system locale per user session - not changing language

Sorry for the lack of updates. Work and life has taken over my free time...

I have an exact local test system so I am able to remove the xrdp out of the mix.

Here is what is going on now:

I log in from a shutdown state or reboot and here is the following outputs of locale -a, locale and localectl.

$ locale -a
C
dutch
en_US.utf8
nl_NL
nl_NL@euro
nl_NL.iso88591
nl_NL.iso885915@euro
nl_NL.utf8
POSIX

...

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

...

$ localectl
   System Locale: LANG=en_US.UTF-8
       VC Keymap: n/a
      X11 Layout: n/a

From here I will run unset LANG and source /etc/profile.d/locale.sh

$ unset LANG
$ source /etc/profile.d/locale.sh

Here is the updated locale

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

The locale -a and localectl remain unchanged.

The language still remains unchanged and when I log off and/or reboot, locale reverts back to en_US.UTF-8.

Offline

#19 2019-08-14 20:24:20

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,834

Re: Overriding system locale per user session - not changing language

I log in …

How and into what?
A non-login bash that you start later on in xterm or so isn't expected to source /etc/profile

The language still remains unchanged

Language where? This will only affect processes started after the change and from the shell where you sourced /etc/profile.d/locale.sh

Online

#20 2019-08-14 21:06:05

CK_Jazz
Member
Registered: 2016-09-26
Posts: 14

Re: Overriding system locale per user session - not changing language

I am using LightDM to log into Mate locally.

The user I am logging in with has a ~/.config/locale.conf file configured per the wiki.

Offline

#21 2019-08-14 21:37:14

lucas2santos
Member
From: Brazil
Registered: 2019-06-17
Posts: 10

Re: Overriding system locale per user session - not changing language

There is something strange here. Could you post the whole content of your /etc/locale.gen?

$ cat /etc/locale.gen

Last edited by lucas2santos (2019-08-14 21:43:18)

Offline

#22 2019-08-14 21:43:19

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,834

Re: Overriding system locale per user session - not changing language

He doesn't have a problem w/ the locale per se, but /etc/profile.d/locale.sh isn't sourced by the session for whatever reason.

@CK_Jazz, lightdm is supposed to invoke a session wrapper, by default /etc/lightdm/Xsession (which in turn would source /etc/profile among others) - did you change anything?

What if you
a) do NOT unset LANG
b) source /etc/profile instead of the language script?

Online

#23 2019-08-14 21:51:02

lucas2santos
Member
From: Brazil
Registered: 2019-06-17
Posts: 10

Re: Overriding system locale per user session - not changing language

seth wrote:

He doesn't have a problem w/ the locale per se, but /etc/profile.d/locale.sh isn't sourced by the session for whatever reason.

His locale.conf is set as "nl_NL.utf8". Shouldn't it be "nl_NL.UTF-8" instead, as it should be in locale.gen file?

Last edited by lucas2santos (2019-08-14 22:04:23)

Offline

#24 2019-08-14 22:12:15

loqs
Member
Registered: 2014-03-06
Posts: 18,893

Re: Overriding system locale per user session - not changing language

The entry nl_NL.UTF-8 UTF-8 is listed by `locale -a` as nl_NL.utf8 indicating locale recognizes and will accept that string.

Offline

#25 2024-08-12 06:28:09

cvdgenugten
Member
Registered: 2024-08-12
Posts: 1

Re: Overriding system locale per user session - not changing language

Hi, opening this thread as I ran into the same issue.

Archlinux
Minimal mate-desktop setup
Multiuser environment with ldap authentication
Xrdp set-up for my users to connect to this server

As some users are Dutch, some are English and some speak yet another language, I needed to set-up the language in mate desktop environment when they connect to xrdp. Xrdp does source the system locale, however will not look into the user's override as suggested in this post as well in ~/.config/locale.conf

Fix:
Place your desired locale in ~/.config/locale.conf, for example LANG=nl_NL.UTF-8

In /etc/xrdp/startwm.sh just after #start the window manager, unset the LANG variable and source the /etc/profile.d/locale.sh:

....
#start the window manager
wm_start()
{
  if [ -r /etc/locale.conf]; then
    . /etc/locale.conf
    export LANG LANGUAGE
  fi
  #additional config added here to override the language settings, should they be configured in a user's ~/.config/locale.conf:
  unset LANG
  source /etc/profile.d/locale.sh
....

No need to restart xrdp, just login again with the user affected and it should work instantly.

Offline

Board footer

Powered by FluxBB