Comment 11 for bug 868149

Revision history for this message
Martin Pitt (pitti) wrote : Re: [Bug 868149] Re: Need to set $LANG from .dmrc for backwards compatibility

Gunnar Hjalmarsson [2011-10-06 19:10 -0000]:
> > Did it change in the new GDM, or is this an Ubuntu specific thing?
>
> It's an Ubuntu specific thing in GDM 2. (In GDM 3 ~/.dmrc isn't used.)

Argh, why did we use that? Whenever we discussed that we were quite
adamant to not redefine the meaning of existing fields, to not break
other DMs and backwards compat. :-( As it seems that existing
configuration files can now contain a locale (as it should), or a
language (which really is broken), I guess we can only apply a
heuristic, as e. g. en_GB is both (but more likely a language, as we
never officially supported non-UTF8 locales and gdm never allowed you
to set one).

> Otherwise, the language2locale() function I proposed in
> https://code.launchpad.net/~gunnarhj/lightdm/lang-chooser/+merge/78226
> might be handy. You could use that function to convert ~/.dmrc
> "Language" values that does not contain a '.' before setting LANG.

Please note. By definition, a language name does not have enough
information to turn it into a proper locale for $LANG, unless you also
know which country the user is. I rather propose to apply a heuristic
to find out whether it's a language or a locale, and assign it to
$LANGUAGE/$LANG respectively.

I think this heuristic should work, assuming that we only support
UTF-8 in .dmrc:

  '.' in the name → locale; break
  no '_' in the name → language; break
  now we have something like ll_CC[suffix]
  ll in {'en', 'es', 'zh', 'pt'} → language
  else it's a locale

That works for any ll_CC.UTF-8 (locale), simple language ("de"),
specially handled country specific language (en_GB, zh_TW), UTF-8
locales without suffix (sr_RS@latin, sr_RS).

Martin
--
Martin Pitt | http://www.piware.de
Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)