Sets $LANG to invalid value "de"

Bug #793366 reported by Martin Pitt on 2011-06-06
60
This bug affects 14 people
Affects Status Importance Assigned to Milestone
language-selector (Ubuntu)
Undecided
Gunnar Hjalmarsson
lightdm (Ubuntu)
Undecided
Gunnar Hjalmarsson

Bug Description

Binary package hint: lightdm

When I moved from gdm to lightdm, I now get an invalid locale:

$ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Kann LC_ALL nicht auf die Standard-Lokale einstellen: Datei oder Verzeichnis nicht gefunden
LANG=de
LANGUAGE=de:en
LC_CTYPE="de"
LC_NUMERIC="de"
LC_TIME="de"
LC_COLLATE="de"
LC_MONETARY="de"
LC_MESSAGES=de_DE.UTF-8
LC_PAPER="de"
LC_NAME="de"
LC_ADDRESS="de"
LC_TELEPHONE="de"
LC_MEASUREMENT="de"
LC_IDENTIFICATION="de"
LC_ALL=

It seems it takes the "de" from my ~/.dmrc, which was set up that way by gdm:
$ cat .dmrc
[Desktop]
Language=de
Langlist=de:en
LCMess=de_DE.UTF-8
Layout=us
Session=gnome

From that, gdm sets

LANG=de_DE.UTF-8
LANGUAGE=de:en

while lightdm sets
LC_MESSAGES=de_DE.UTF-8
LANG=de
LANGUAGE=de:en

I'm not entirely sure how gdm derives an appropriate $LANG locale name from just a language name. I'm subscribing Gunnar about this.

BTW, I noticed that the current lightdm does not have a language/keyboard chooser at all any more. It used to have one a week or two ago?

Gunnar Hjalmarsson (gunnarhj) wrote :

As soon as I noticed that lightdm will be the default dm in Oneiric, I realized that there is a need to patch lightdm similarly to how we patch gdm. It seems that lightdm uses the original (simplistic) gdm method to set the i18n environment.

gdm takes the $LANG value from ~/.profile or /etc/default/locale. (The $LC_MESSAGES value is derived from a language name, though, either in Xsession - the language_environment_update() function - or language-selector.)

As regards language/keyboard choosers, those features seem to be available.
http://www.freedesktop.org/wiki/Software/LightDM/Design
I take it that there is a need to make a design decision on whether the language/keyboard choosers shall be enabled in Ubuntu by default. Personally I'd prefer that they are.

Btw, when I messed with gdm patches I noticed that the keyboard layout chooser seems to have been dropped in gdm 3.

Changed in lightdm (Ubuntu):
assignee: nobody → Gunnar Hjalmarsson (gunnarhj)
status: New → Confirmed
Gunnar Hjalmarsson (gunnarhj) wrote :

I have patched lightdm so it no longer assigns an invalid value to LANG. However, at this time ~/.profile is ignored, so LANG gets populated with the system value, which lightdm sets by sourcing /etc/default/locale (in /etc/init/lightdm.conf, I think). I take it for granted that lightdm will source ~/.profile somehow as is requested in bug #794315. (I miss a dash script like /etc/gdm/Xsession - is "PreSession" going to serve that purpose?)

lightdm now also sets the language environment variables correctly from dmrc. language-selector has been modified so it updates lightdm's dmrc cache file and ~/.dmrc when lightdm is in use.

Changed in language-selector (Ubuntu):
assignee: nobody → Gunnar Hjalmarsson (gunnarhj)
status: New → In Progress
Changed in lightdm (Ubuntu):
status: Confirmed → In Progress
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package language-selector - 0.41

---------------
language-selector (0.41) oneiric; urgency=low

  * LanguageSelector/LanguageSelector.py and LanguageSelector/LocaleInfo.py:
    Take also LightDM's dmrc files into account when reading and saving
    data (LP: #793366).
 -- Gunnar Hjalmarsson <email address hidden> Tue, 21 Jun 2011 14:58:24 +0200

Changed in language-selector (Ubuntu):
status: In Progress → Fix Released
Gunnar Hjalmarsson (gunnarhj) wrote :

@Robert
The v. 0.41 changes in language-selector presuppose that lightdm's dmrc cache files are user editable. We'd better reach a conclusion on that soon, because currently, when you try to change language from language-selector, it fails.

Robert Ancell (robert-ancell) wrote :

The cache files are not user editable. The purpose of the cache is lightdm reads from it if ~/.dmrc does not exist (e.g. if the home directory is not yet mounted). if changing ~/.dmrc does not updated lightdm, then this is a bug in lightdm.

Gunnar Hjalmarsson (gunnarhj) wrote :

What about the question I asked on the merge proposal then? If the user changes ~/.dmrc, and lightdm reads from the cache at next login because HOME isn't yet mounted, it reads old info, doesn't it?

We also have the situation when the user sets a new language at login. If HOME isn't mounted then, only the cache file will be updated, and if the user opens language-selector in that session, l-s will read old info from ~/.dmrc since the cache file isn't even user readable.

As regards GDM, these situations are taken care of by both GDM and language-selector read from and write to the cache file at first hand (which basically makes ~/.dmrc redundant). I'm not saying that this is the only way to deal with it, but I want to make sure that we don't introduce buggy behavior.

Sam_ (and-sam) wrote :

If it helps, at the beginning this bug affected me too, but I issued export LANG=de_DE.UTF-8, since locale on Natty desktop pc is set up like this, although I didn't manually export to ~/.profile.

Stefano Rivera (stefanor) wrote :

Sam: I edited by .dmrc to have LANG=en_ZA.UTF-8, and removed LCMess.

I couldn't see any way to fix it without editing .dmrc by hand.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lightdm - 0.4.1-0ubuntu1

---------------
lightdm (0.4.1-0ubuntu1) oneiric; urgency=low

  * New upstream release
    - Fixes (LP: #793366)
  * debian/lightdm.conf:
  * debian/guest-session-cleanup.sh:
  * debian/guest-session-setup.sh:
    - Enable guest session
 -- Robert Ancell <email address hidden> Thu, 30 Jun 2011 17:04:25 +0100

Changed in lightdm (Ubuntu):
status: In Progress → Fix Released
Robert Ancell (robert-ancell) wrote :

The fix in LightDM is it no longer sets any locale environment. The defaults for LANG and LANGUAGE are sourced from /etc/default/locale and then it is up to the users .profile to set their language (which is populated by language-selector). The fields in ~/.dmrc are ignored entirely.

Yves-Alexis Perez (corsac) wrote :

Why ignore completely the fields in .dmrc? Afaict they are useful when set (wether from GDM or lightDM). .profile isn't use by everybody and language-selector either (especially outside of Ubuntu).

Gunnar Hjalmarsson (gunnarhj) wrote :

@Robert
Calling that a fix is obviously related to your statement in bug #803858 about not providing a language chooser. It was unexpected news to me.
https://lists.ubuntu.com/archives/ubuntu-desktop/2011-June/003081.html

Btw, are you talking about Ubuntu or upstream or both? Personally I'd prefer that we keep providing the opportunity to set the display language at login, at least in Ubuntu.

If I understand it correctly, the code for a language widget is still there, and the (.dmrc based) Natty model for how a language chooser may play together with language-selector can be applied to LightDM as well.

I fully understand that you are loaded with various aspects of LightDM, and I offer to help fix this in a similar way as it works in Natty with GDM. If somebody re-activates the LightDM language chooser (as is), I'll try to take it from there.

Robert Ancell (robert-ancell) wrote :

Yves-Alexis, the fields in .dmrc are only there so the greeter can know which language to set by default in the list of options. The locale settings must be set externally to the display manager as it is not the only method of logging into the system (e.g. text terminal logins). So by LightDM not touching the locale settings it uses the correct settings as defined by the distribution.

Gunnar, I've closed this bug because it fixes the specific problem which was setting the locale to an invalid value. There are some other issues here which need to be tracked in other bugs:
- Does LightDM support a greeter overriding the user language (currently broken, not opposed to solving this)
- Does the Ubuntu greeter provide an appropriate method for users to switch languages?

Gunnar Hjalmarsson (gunnarhj) wrote :

@Robert
As you may have seen already, I sent a message about the language chooser topic to the ubuntu-desktop list. https://lists.ubuntu.com/archives/ubuntu-desktop/2011-July/003137.html Looking forward to replies from you and others.

You make me curious when you write: "a greeter overriding the user language (currently broken". What do you mean by that? And broken, how?

Yves-Alexis Perez (corsac) wrote :

Robert, I disagree about lightdm not touching the locale setting. If there are other ways to login to the system, fine. That doesn't prevent to read .dmrc which has the correct locale selected by the user.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Bug attachments