Firefox interface language set to LANG, ignores LANGUAGE

Bug #550222 reported by Jeroen Hoek
78
This bug affects 14 people
Affects Status Importance Assigned to Milestone
Mozilla Firefox
Confirmed
Medium
Ubuntu Translations
Triaged
Medium
Unassigned
amule (Ubuntu)
Invalid
Undecided
Unassigned
firefox (Ubuntu)
Triaged
Medium
Unassigned

Bug Description

Binary package hint: firefox

Firefox appears to misinterpret the locale environment variables set by the Language Support tool. It uses LANG instead of LANGUAGE.

Use case:
I am a software engineer, so I prefer to have my user interface language set to English ("en_GB" if possible, fall back to "en"). I'm Dutch and live in the Netherlands, so all measurements, paper sizes, and currency localization are set to "nl_NL". This works for all GTK+ applications as expected. Firefox however sets its interface language to Dutch instead of English.

As far as I can tell, the Language Support tool in Lucid Lynx sets LANGUAGE and LANG:

LANG=nl_NL.utf8
LANGUAGE=en_GB:en

This seems to be a bug in Firefox.

Possibly related bugs:
bug 539761 (LC_MESSAGES misinterpreted)

Tags: patch
Arne Goetje (arnegoetje)
Changed in firefox (Ubuntu):
milestone: none → ubuntu-10.04
status: New → Confirmed
importance: Undecided → Medium
David Planella (dpm)
description: updated
Steve Langasek (vorlon)
Changed in firefox (Ubuntu):
milestone: ubuntu-10.04 → none
Revision history for this message
Martin Andersson (martin-olof-andersson) wrote : Re: [Bug 550222] Re: Firefox interface language set to LANG, ignores LANGUAGE

Amazing how fast you guys responded to this!

Thank you!

I am looking forward ot the update.

Martin

2010/5/6 Steve Langasek <email address hidden>

> ** Changed in: firefox (Ubuntu)
> Milestone: ubuntu-10.04 => None
>
> --
> Firefox interface language set to LANG, ignores LANGUAGE
> https://bugs.launchpad.net/bugs/550222
> You received this bug notification because you are a direct subscriber
> of a duplicate bug.
>

David Planella (dpm)
Changed in ubuntu-translations:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
In , David Planella (dpm) wrote :

User-Agent: Mozilla/5.0 (X11; U; Linux i686; ca; rv:1.9.2.8) Gecko/20100723 Ubuntu/10.10 (maverick) Firefox/3.6.8
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; ca; rv:1.9.2.8) Gecko/20100723 Ubuntu/10.10 (maverick) Firefox/3.6.8

(Forwarded from the downstream bug report at https://bugs.launchpad.net/ubuntu-translations/+bug/550222)

Firefox appears to misinterpret the locale environment variables set by the Language Support tool. It uses LANG instead of LANGUAGE.

Use case:
I am a software engineer, so I prefer to have my user interface language set to English ("en_GB" if possible, fall back to "en"). I'm Dutch and live in the Netherlands, so all measurements, paper sizes, and currency localization are set to "nl_NL". This works for all GTK+ applications as expected. Firefox however sets its interface language to Dutch instead of English.

As far as I can tell, the Language Support tool in Lucid Lynx sets LANGUAGE and LANG:

LANG=nl_NL.utf8
LANGUAGE=en_GB:en

Reproducible: Always

Steps to Reproduce:
1. Set the LANGUAGE environment variable to LANGUAGE=en_GB:en
2. Set the LANG environment variable to LANG=nl_NL.utf8
3. Start Firefox
Actual Results:
Firefox starts up in Dutch, as per the value in LANG

Expected Results:
Firefox should start in English, as per the value in LANGUAGE, which seems to be ignored.

According to [1], "The LANGUAGE environment variable is examined first to determine the message catalogs to be used.". This is the behaviour for all GTK applications in a Linux-based OS.

[1] http://www.openi18n.org/docs/html/LI18NUX-2000-amd4.htm

Possibly related downstream bugs:
* https://bugs.launchpad.net/bugs/539761 (LC_MESSAGES misinterpreted)

Changed in firefox:
importance: Undecided → Unknown
status: New → Unknown
Revision history for this message
In , L10n-mozilla (l10n-mozilla) wrote :

http://mxr.mozilla.org/mozilla-central/source/intl/locale/src/nsLocaleService.cpp#186 checks for LANG.

Moving to core intl for triage, as I know jack about the specs there.

Changed in firefox:
status: Unknown → New
Revision history for this message
In , Smontagu (smontagu) wrote :

CC-ing Wolfgang, who is working on this code in bug 568459

Revision history for this message
In , Mozilla (mozilla) wrote :

LANGUAGE should be supported I'd say. It's a gettext feature and therefore petty much standard on Linux systems.
With current nsLocale etc. it's a bit of a pain to implement it apparently though.
For example LANGUAGE can be a list of colon seperated locale names and nsLocale has no data structure for LANGUAGE. I'm currently a bit into the code and will try if I can come up with a patch.

Changed in firefox:
status: New → Confirmed
Revision history for this message
Micah Gersten (micahg) wrote :

Marking this Triaged as we have an upstream bug.

Changed in firefox (Ubuntu):
status: Confirmed → Triaged
Revision history for this message
In , L10n-mozilla (l10n-mozilla) wrote :

I would like to add one thing: I read David's env use as a hack to actually get a en_NL. We're *very* unlikely to support that, IMHO.

Revision history for this message
In , David Planella (dpm) wrote :

Axel,

The bug is not about adding any kind of hack, and in no way I've (well, the original downstream poster) suggested creating or supporting a en_NL locale.

The bug is about supporting the LANGUAGE gettext environment variable in Linux, a well established standard in all distributions [1] [2].

I'll be happy to reword the bug description to make it clearer, if necessary.

Thanks.

[1] http://www.gnu.org/software/hello/manual/gettext/Locale-Environment-Variables.html
[2] http://www.openi18n.org/docs/html/LI18NUX-2000-amd4.htm

Revision history for this message
In , L10n-mozilla (l10n-mozilla) wrote :

My comment is about filing more bugs to get non-language pieces of our localized content to actually follow the LANG instead of the LANGUAGE setting. Say, time formats, or maybe at some point search engines.

Revision history for this message
In , Mozilla (mozilla) wrote :

I've tested a minimalistic approach to support LANGUAGE. The biggest issue with that is that multiple definitions are not really supported. The other thing is that I reuse/override LC_MESSAGES internally but I understand that this is actually the result anyway.

(In reply to comment #6)
> My comment is about filing more bugs to get non-language pieces of our
> localized content to actually follow the LANG instead of the LANGUAGE setting.
> Say, time formats, or maybe at some point search engines.

This is sensible but not primary topic of this bug as as I understand.

Revision history for this message
In , David Planella (dpm) wrote :

(In reply to comment #7)
> I've tested a minimalistic approach to support LANGUAGE.

That's great, thanks for working on that!

> The biggest issue with that is that multiple definitions are not
> really supported.

Are you referring here to the behaviour of supporting multiple language fallbacks (LANGUAGE=de:es)?

It would be nice to implement this, but having support for the main locale but be a good start already.

> The other thing is that I reuse/override LC_MESSAGES internally but I
> understand that this is actually the result anyway.

If I understand correctly that you are referring to LANGUAGE overriding not only LANG, but also the LC_xxx categories, that's fine. According to the gettext documentation, the order of preference (unless LC_ALL or LANG is specified as "C") is:

1. LANGUAGE
2. LC_ALL
3. LC_xxx, according to selected locale category: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES, ...
4. LANG

Revision history for this message
In , Mozilla (mozilla) wrote :

(In reply to comment #8)
> > The biggest issue with that is that multiple definitions are not
> > really supported.
>
> Are you referring here to the behaviour of supporting multiple language
> fallbacks (LANGUAGE=de:es)?

Yes.

> It would be nice to implement this, but having support for the main locale but
> be a good start already.

Mozilla has no real idea which locales are supported. AFAIK at some point when a locale is supposed to be loaded and it fails it just falls back to en_US.
But I agree that it would be nice to support it.

> If I understand correctly that you are referring to LANGUAGE overriding not
> only LANG, but also the LC_xxx categories, that's fine. According to the
> gettext documentation, the order of preference (unless LC_ALL or LANG is
> specified as "C") is:
>
> 1. LANGUAGE
> 2. LC_ALL
> 3. LC_xxx, according to selected locale category: LC_CTYPE, LC_NUMERIC,
> LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES, ...
> 4. LANG

- LC_* are authoritative. Every LC_* which is not set manually will be set to
  the value of LANG.
- LC_ALL overrides all other LC_* settings.
- LANGUAGE exists besides LC_MESSAGES to override it for UI language

That fits your above description with the exception that LANGUAGE is only overriding LC_MESSAGES effectively.

shankao (shankao)
Changed in amule (Ubuntu):
status: New → Confirmed
Revision history for this message
David Planella (dpm) wrote :

shankao,

Thanks for adding the amule task. However, this particular bug is for Firefox, so it would be great if you could file a separate bug for amule instead.

Changed in amule (Ubuntu):
status: Confirmed → Invalid
Changed in firefox:
importance: Unknown → Medium
Revision history for this message
In , Jeroen Hoek (mail-jeroenhoek) wrote :

(I am the downstream reporter)

Is there any kind of time-frame for resolving this bug? It has been a problem for quite a while now. The upcoming round of distro releases probably won't ship a fix either.

Comment 8:
Full LANGUAGE support would be great, but as you point out, even just supporting the first locale mentioned would help a lot.

Revision history for this message
In , Mozilla (mozilla) wrote :

Status from my POV:
I most likely don't have the time to implement full LANGUAGE support for a list.

I'm not sure if the fast partial support is enough for Mozilla to accept it.
I will attach my current patch nevertheless.

Revision history for this message
In , Mozilla (mozilla) wrote :

Created attachment 478760
simple patch

Patch only supporting one item in the $LANGUAGE environment.

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

Using LANG instead of LANGUAGE is not the default behavior of Firefox. For some reason, Debian seems to have created the problem through a firefox.js file with Debian specific preferences:

$ grep -B1 'matchOS' /etc/firefox/pref/firefox.js
// Use LANG environment variable to choose locale
pref("intl.locale.matchOS", true);

I figured out how to change the behavior to our liking, and the solution is described in the patch (or hack) I attached to this bug. The same solution works just as well for Thunderbird, btw.

Changed in firefox (Ubuntu):
status: Triaged → In Progress
Revision history for this message
Jeroen Hoek (mail-jeroenhoek) wrote :

Just adding the user_pref("intl.locale.matchOS", false); line to user.js fixes the problem for me. Thank you for the tip.

Do we know why (and by whom) that option was set in the Debian-provided preferences override?

Revision history for this message
Jeroen Hoek (mail-jeroenhoek) wrote :

#15:
Of course, it fixes the problem for me by setting the language to English, which is the default. You still need to tell Firefox which language to use if you want any other language.

Revision history for this message
Felix Dreissig (f30) wrote :

The fix works fine for me, but are you sure that this is really a Debian-specific problem?
I have absolutely no idea of the Mozilla code, but considering the very serious and advanced discussion at the Mozilla bugtracker, I can't really believe that the whole thing is only about a Debian config file.

tags: added: patch
Revision history for this message
Micah Gersten (micahg) wrote :

Resetting bug to Triaged. matchOS was added so Firefox automatically uses the language of the host system. I'll have to look at the UILocale startup option since we do have a wrapper script in place already.

Changed in firefox (Ubuntu):
status: In Progress → Triaged
Revision history for this message
Nicolò Chieffo (yelo3) wrote :

Does the patch also fix language preferences order, if the more preferred language is not available?

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Can you please not mark attachments as patches unless they really are patches.

Thanks

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

And please don't link branches to the bug, unless they contain a fix for the issue

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

Since I'm questioning a Debian specific configuration, I filed a Debian bug also:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=598244

Revision history for this message
Micah Gersten (micahg) wrote :

We don't get Firefox from Iceweasel, I'm closing that bug.

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Indeed. And setting intl.locale.matchOS is intentional (not a bug). Without it, Firefox gets the language from the general.useragent.locale preference rather than the users environment. I've got no idea how that could work reliably on Ubuntu, seeing as we localize that preference....

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

@Jeroen Hoek, comment #15
You are welcome. I don't know why or by whom.

@Felix Dreissig, comment #17
No, I'm not sure. What I know about the background is included in the bug I filed with Debian (see comment #22), and that firefox.js file indicates that the problem is Debian-specific IMO.

@Micah Gersten, comment #18
The Ubuntu l10n / i18n model, not least the language-selector package, seems to assume that LANGUAGE is for language while LANG is for other locale stuff. Also, please see my comment #21 in bug 553162.

As regards the wrapper, I suppose there is a more suitable place for that code. Great if you check it out!

@Nicolò Chieffo, comment #19
Well, no. English is always there as a fall back language, but AFAIK Ubuntu cannot currently handle a non-English fall back language.

@Chris Coulson, comment #20 and comment #21
I hesitated as regard the patch mark... Sorry! Pls bear with a newbie in this community.

@Micah Gersten, comment #23
I disapprove of your action. I identified a possible issue, and tried to communicate it with "upstream". Obviously we got some configuration stuff from Debian, and Debian wants the applicable package name just like that.

@Chris Coulson, comment #24
Also intentional code may become a bug later on, if it proves to cause unexpected problems, right?

> I've got no idea...
I for one have a very clear idea. How about testing the solutions I shared here and in bug 553162? Only after that I think it will be meaningful to talk about pros and cons.

Revision history for this message
Micah Gersten (micahg) wrote : Re: [Bug 550222] Re: Firefox interface language set to LANG, ignores LANGUAGE

 As I wrote, Firefox doesn't come from Debian, therefore, Debian isn't
upstream in this case.

On 09/27/2010 06:07 PM, Gunnar Hjalmarsson wrote:
> @Felix Dreissig, comment #17
> No, I'm not sure. What I know about the background is included in the
bug I filed with Debian (see comment #22), and that firefox.js file
indicates that the problem is Debian-specific IMO.
>
> @Micah Gersten, comment #23
> I disapprove of your action. I identified a possible issue, and tried
to communicate it with "upstream". Obviously we got some configuration
stuff from Debian, and Debian wants the applicable package name just
like that.

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

I have modified the GDM patch attached to bug 553162, and now that patch fixes the problem with programs, e.g. Firefox, that don't recognize $LANGUAGE. Even if the solution provided as an attachment to this bug works well, the code in the GDM patch is more elegant IMO.

If you want to deal with this issue, without implementing the bug 553162 patches, and assuming that you want menus and messages translated into German, you can just add this line to the bottom of your ~/.profile file:

    export LC_MESSAGES="de_DE.utf8"

Revision history for this message
Martin Andersson (martin-olof-andersson) wrote : Re: [Bug 550222] Re: Firefox interface language set to LANG, ignores LANGUAGE

Being completely out of the programming in this case,
my 5 öre is to say that it is not really good to have two
global variables with almost same names, but slightly
different meanings, and also same but slightly different
meanings for their names. It could be a good idea to change
both the variable names LANG and LANGUAGE to something
more descriptive, I think.

Martin

2010/10/5 Gunnar Hjalmarsson <email address hidden>

> I have modified the GDM patch attached to bug 553162, and now that patch
> fixes the problem with programs, e.g. Firefox, that don't recognize
> $LANGUAGE. Even if the solution provided as an attachment to this bug
> works well, the code in the GDM patch is more elegant IMO.
>
> If you want to deal with this issue, without implementing the bug 553162
> patches, and assuming that you want menus and messages translated into
> German, you can just add this line to the bottom of your ~/.profile
> file:
>
> export LC_MESSAGES="de_DE.utf8"
>
> --
> Firefox interface language set to LANG, ignores LANGUAGE
> https://bugs.launchpad.net/bugs/550222
> You received this bug notification because you are a direct subscriber
> of a duplicate bug (576162).
>

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

@ Martin A.
It's true that descriptive variable names is good programming practice as a general rule. However, here we are talking about two environment variables, whose names are beyond the control of the Ubuntu community. When you deal with i18n and l10n as a programmer, you simply need to learn the meaning of those variables.

Revision history for this message
Micah Gersten (micahg) wrote :

This shouldn't be a duplicate as Firefox is not respecting the environment variables properly. There is already a partial patch in the upstream tracker for this issue.

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

@ Micah Gersten, David Planella
I marked this bug, and with that its duplicates, as a duplicate of bug 553162, since the issue reported here will be solved by the solution being discussed at bug 553162. Please feel free to test the patches for yourself:

https://launchpad.net/~gunnarhj/+archive/locale-test

I have noticed that you reverted my action, so I now understand that you, unlike me, prefer to consider inability to recognize LANGUAGE to be a bug per se. But isn't that disputable as regards non-GNU apps? Anyway, it's of course good if as many apps as possible recognize LANGUAGE and its priority list feature. My apologies if you concluded from my action that I'm of another opinion.

Revision history for this message
David Planella (dpm) wrote :

El ds 16 de 10 de 2010 a les 22:53 +0000, en/na Gunnar Hjalmarsson va
escriure:
> @ Micah Gersten, David Planella
> I marked this bug, and with that its duplicates, as a duplicate of bug 553162, since the issue reported here will be solved by the solution being discussed at bug 553162. Please feel free to test the patches for yourself:
>
> https://launchpad.net/~gunnarhj/+archive/locale-test
>

Hi Gunnar,

Both Micah and I gave clear information on why we undid the duplication.
they are two different bugs:

* One affecting the interaction between gdm and language-selector in
setting LANG and LANGUAGE (and somewhere along the way it seems
language-selector seems to fail setting LC_* as well?).

* One affecting Firefox (and also other apps such as OpenOffice.org, for
which there is a task in one of the duplicates), where it does not
support the $LANGUAGE variable.

It does not matter if fixing gdm/language-selector will hide the second
bug: Firefox and other apps will still not support $LANGUAGE. If they
are used in environments where the vast majority of applications support
gettext, I think it's a valid request to expect them to implement the
gettext variables, so they do not have to be special-cased.

> I have noticed that you reverted my action, so I now understand that
> you, unlike me, prefer to consider inability to recognize LANGUAGE to be
> a bug per se.

Yes, as explained in the Firefox bug, both upstream and downstream.

> But isn't that disputable as regards non-GNU apps? Anyway,
> it's of course good if as many apps as possible recognize LANGUAGE and
> its priority list feature. My apologies if you concluded from my action
> that I'm of another opinion.
>

No need to apologize. It's completely fine to disagree!

Thanks for your work on this so far.

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

As regards disagreement... While I may think that a request for recognizing LANGUAGE is a feature request, you think it's a bug. Not much of a disagreement to mind about, I'd say. :) Let's talk about the issue at hand instead.

The patches attached to bug 553162 make sure that the first item in LANGUAGE coresponds with LC_MESSAGES, whose value Firefox respects. Consequently, once those patches have been implemented, the simple Firefox patch that Wolfgang Rosenauer wrote, and which only supports one LANGUAGE item, would in effect become a no-op.

The point with the gettext variable LANGUAGE is its priority list.
http://www.gnu.org/software/gettext/manual/gettext.html#The-LANGUAGE-variable

Hence I'd say that making an app recognize LANGUAGE ought to mean that it's given the ability to respect the whole list, or else it doesn't matter.

Revision history for this message
hardik (hardik-soni) wrote :
Revision history for this message
In , Jo-hermans (jo-hermans) wrote :

*** Bug 595299 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Jo-hermans (jo-hermans) wrote :

Changing title, since it also affects other applications like Thunderbird.

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.