Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
GNOME: how to set language for individual user
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
NP_complete
Tux's lil' helper
Tux's lil' helper


Joined: 21 Mar 2009
Posts: 100

PostPosted: Tue Feb 09, 2016 1:48 am    Post subject: GNOME: how to set language for individual user Reply with quote

I have two users on the same machine. One wants to have everything in en_US, the other in de_DE. The default is en_US. Changing the language in Gnome Settings has a partial effect. For example, in the following output of 'locale'
Quote:
LANG=en_US.utf8
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE="en_US.utf8"
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER="en_US.utf8"
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=
LC_PAPER changes to "de_DE" while, e.g., LC_MESSAGES does *not*. My Gnome Terminal menu is in German, and almost everything else is in English. Go figure. 'locale -a' prints
Quote:
C
de_DE
de_DE@euro
de_DE.iso88591
de_DE.iso885915@euro
de_DE.utf8
deutsch
en_US
en_US.iso88591
en_US.utf8
german
POSIX
Is there a good way to make GNOME switch between languages depending on the user? By "switch", I mean FULLY and AUTOMATICALLY. Many thx.

PS My LINGUAS variable is set to "de en".
Back to top
View user's profile Send private message
v_andal
Guru
Guru


Joined: 26 Aug 2008
Posts: 521
Location: Germany

PostPosted: Tue Feb 09, 2016 8:27 am    Post subject: Reply with quote

I don't use Gnome, so I can't give you exact answer, but generally speaking, you should look at how your display manager starts gnome session (it depends on display manager). Normally the startup involves execution of some script in users home directory. According to this https://wiki.archlinux.org/index.php/xprofile GDM executes ~/.xprofile file. So you can try to put into this file your "export LANG=de_DE.utf8" for the user that wants to have DE as language.

If ~/.xprofile does not work, then you may want to look at creation of some script in /etc/gdm/PostLogin/ directory as it is described here https://help.gnome.org/admin/gdm/stable/configuration.html.en and telling that script to execute scripts from users home directory (that is if you use GDM as login manager)
Back to top
View user's profile Send private message
fengalin
n00b
n00b


Joined: 09 Feb 2008
Posts: 17

PostPosted: Sun Feb 21, 2016 5:57 pm    Post subject: Reply with quote

I have the exact same issue. System's locale is fr_FR.utf8 and I want one user to be able to use a polish Gnome session. I followed this: https://wiki.gentoo.org/wiki/Localization/Guide

Code:
$ localectl list-locales
fr_FR
fr_FR.iso88591
fr_FR.iso885915@euro
fr_FR.utf8
fr_FR@euro
french
pl_PL
pl_PL.iso88592
pl_PL.utf8
polish


Code:
$ cat /etc/portage/make.conf | grep LINGUAS
LINGUAS="fr es en pl"


I rebuilt the locales and all the packages I could think about. As a matter of fact, I rebuilt Gnome entirely when version 3.18 arrived in portage.

In the polish user's session, in Gnome's Country and Language setting panel, I set both Language and Format to polish. I got a message asking to restart the session. After which, the date format was polish, a few application menus displayed in polish, but the rest of the desktop remained in french (Appplication Menu, Control Panel, ...).

I searched the web and tried setting this:
Code:
polish_user ~ $ cat .config/locale.conf
LANG=pl_PL


I followed v_andal's suggestion and read gdm's configuration page. I tried this:
Code:
polish_user ~ $ cat .dmrc
[Desktop]
Session=gnome
Language=pl_PL


But it didn't help either.

There might be something specific to do on a Gentoo system as I could properly configure a Cent OS 7 session from Gnome's Control Panel. But I really don't know what to do.
Back to top
View user's profile Send private message
v_andal
Guru
Guru


Joined: 26 Aug 2008
Posts: 521
Location: Germany

PostPosted: Mon Feb 22, 2016 8:19 am    Post subject: Reply with quote

First of all, you should use "pl_PL.UTF-8" as locale name. Second, have you checked permissions on your ~/.dmrc file? It should be rw-r-r (0644).
Finally, I would still try to put LANG=pl_PL.UTF-8 into ~/.xprofile file.
Back to top
View user's profile Send private message
fengalin
n00b
n00b


Joined: 09 Feb 2008
Posts: 17

PostPosted: Mon Feb 22, 2016 9:56 pm    Post subject: Reply with quote

Thank you v_andal: setting LANG=pl_PL.utf8 in ~/.xprofile solved the problem in most applications! A couple of them don't seem to use the same mechanism: nautilus, gnome-terminal still display in french. But, this is acceptable.

I'm surprised that all this is not handled automatically when we set the language in the control panel.

Also, I tried resetting the XDG folders with xdg-user-dir-update but they were re-created in english even if ~/.config/user-dirs.locale is set to the polish locale.
Back to top
View user's profile Send private message
v_andal
Guru
Guru


Joined: 26 Aug 2008
Posts: 521
Location: Germany

PostPosted: Tue Feb 23, 2016 10:24 am    Post subject: Reply with quote

Well, the language setting is a big mess. There is "standard" one via locale and locale is set in the environment. There are custom ones, when some system offers alternative location for the setting. There are programs that don't support language changing at all, or support only some languages.

The setting via environment variable is the most supported one (I believe), but one has to provide this setting very early, before the desktop applications are launched. Otherwise they'll inherit old settings. ~/.xprofile is the file that supposed to be pulled in before launch of desktop applications, unfortunately not all desktop sessions support it.

As to names of XDG folders, try to look at this post https://blogs.gnome.org/simos/2007/11/11/localisation-issues-in-home-directory-folders-xdg-user-dirs/
still, proper functioning depends on the same settings active when you call xdg-user-dir-update and when the desktop is initiated. Besides, you have to make sure that $XDG_DATA_HOME is not changed from default.
Back to top
View user's profile Send private message
fengalin
n00b
n00b


Joined: 09 Feb 2008
Posts: 17

PostPosted: Wed Feb 24, 2016 9:36 pm    Post subject: Reply with quote

Thank you again for your support v_andal.

I finally managed to generate the XDG folders in polish using xdg-user-dirs-update. I had to rebuild the package x11-misc/xdg-user-dirs in order to take the polish locale into account.

As far as I can tell, the only recalcitrant applications are nautilus and gnome-terminal. But, that will do it for now.
Back to top
View user's profile Send private message
fengalin
n00b
n00b


Joined: 09 Feb 2008
Posts: 17

PostPosted: Mon Mar 07, 2016 9:03 pm    Post subject: Reply with quote

Just for an update: I'm still struggling, when I find time, to get nautilus and gnome-terminal to be localized in Polish (user's locale, not the system default). I found something "interesting": if I launch nautilus from the docker, the main menu or from gnome's search window, the application displays in the system's locale. Now, if I open a session, open the quick launch window (F2) and type in nautilus, then the application uses the user's locale.

By the way, gnome search window also displays in the system's locale. So I suppose that some applications initialize before the user's locale is exported. From previous attempts, we found that using .xprofile was a good option to define the user's locale. Since then, I figured out that this file was sourced from the gdm session initialization script, which I would have assumed to be executed before any other DM application. I started reading the code, but I didn't find anything specific so far.
Back to top
View user's profile Send private message
alinefr
Tux's lil' helper
Tux's lil' helper


Joined: 05 Jul 2009
Posts: 111
Location: São Paulo, Brasil

PostPosted: Tue Mar 08, 2016 2:22 am    Post subject: Reply with quote

This may looks like a very ugly workaround but what about doing something like this?

In /etc/profile add ~/bin for the non-root login user before any other bin dir in PATH:

/etc/profile:
Code:

if [ "$EUID" = "0" ] || [ "$USER" = "root" ] ; then                                                                                                                                               
    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${ROOTPATH}"                                                                                                               
else                                                                                                                                                                                             
    PATH="~/bin:/usr/local/bin:/usr/bin:/bin:${PATH}"                                                                                                                                             
fi


In the user where the locale is different than the system locale you could create this:

~/bin/gnome-terminal:
Code:

#!/bin/bash
LANG=pl_PL.utf8 /usr/bin/gnome-terminal $*


~/bin/nautilus:
Code:

#!/bin/bash
LANG=pl_PL.utf8 /usr/bin/nautilus $*


Code:

chmod 755 ~/bin/gnome-terminal
chmod 755 ~/bin/nautilus
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum