tags:

views:

1455

answers:

3

I know this question has been answered before, but the answer given is not the complete story:

I went into Firefox's Options->Content and removed all languages except German/Germany, and navigator.language hasn't changed - it's still en-GB (I'm in the UK).

I'm told if I get the German Firefox INSTALL it will work, but I shouldn't need to do that, right?

The useragent string still contains en-GB, too; but the accept-language on HTTP headers IS set correctly. So this seems to be a bug in Firefox, I spent a bit of time wading through their bugzilla, but I can't see this exact bug logged, though to me it seems a pretty huge oversight?

+1  A: 

I would assume that navigator.language returns it's interface language (I assume is GB English), not one that it wants documents in. User-agent string too report which version of firefox was downloaded.

Accept-language is what destination server should check.

I consider this behavior of his quite correct (assuming that it's interface (menus and such) are really in GB english).

Josip Medved
I don't understand why it's good to change one (the accept_language in headers) and not anything else related to locale?
Ian Grainger
@Ian: If I understand your question correctly, the answer is that the UI language and language you want to view your websites in may be different. Example: If I am at an Internet cafe in Germany, the German version of Firefox will most likely be installed. I probably can't install another browser, but I want my websites rendered in English. I change the Accept-Language and now I can view websites in the language of my choice even though the UI is in another language.
Grant Wagner
@Grant: Exactly. That's exactly the problem we have. The user can only change 'accept-language' if they're on a Firefox that's not localized to the language they want to use. And you can't get to that in javascript from Firefox (you can from IE).
Ian Grainger
A: 

If you want the Accept-Language value, you can't retrieve if using client-side JavaScript. You'll have to get it from your server.

If you really want this value in client-side JavaScript, then read it on the server and write it back to the client:

<script type="text/javascript">
// setting the accept language HTTP header value
// in client-side JavaScript from PHP
var acceptLanguage = '<?php echo $_SERVER["HTTP_ACCEPT_LANGUAGE"]; ?>';
</script>
Grant Wagner
I know. This is our current workaround (using ASP.NET):System.Web.HttpContext.Current.Request.UserLangauges.This may sound a bit 'religious', but I don't think we should have to do that, though!
Ian Grainger
+1  A: 

Both navigator.language and the HTTP User-Agent header use the value of the preference "general.useragent.locale", which is hard-coded in intl.properties to the locale of the Firefox build you downloaded: http://mxr.mozilla.org/mozilla-central/source/toolkit/locales/en-US/chrome/global/intl.properties#8

Or for your en-GB build: http://hg.mozilla.org/l10n-central/en-GB/file/88dd673c01f1/toolkit/chrome/global/intl.properties#l8

If you'd like to change it for your build, just load about:config, find general.useragent.locale, double-click it, and change the value.

Ted Mielczarek
@Ted: `navigator.language` may use `general.useragent.locale` (I haven't tested it), but `Accept-Language` doesn't seem to use the `general.useragent.locale` value here. It appears to use `intl.accept_languages`. I manually changed `intl.accept_languages` (i.e. - not through Tools > Options... > Content > Languages) and Live HTTP headers shows Firefox using the new value.
Grant Wagner
@Ted: `phpinfo()` also reports the new value of `intl.accept_languages` in the `Accept-Language` HTTP header so it isn't some odd local phenomenon.
Grant Wagner
Oh oops, I meant "the User-Agent" header there, but I think I got confused by seeing your prior answer. Sorry!
Ted Mielczarek
@Ted: Now it makes sense. Thanks for the edit.
Grant Wagner