views:

940

answers:

4

for example in ie we can use "navigator.systemLanguage" to get language setting but how to get language setting in firefox way?

thx your response.

Cloud

A: 
navigator.language
BipedalShark
A: 

The following JavaScript will get you all the properties of the navigator object that you can look at:

document.write('<pre>');
for (var i in navigator)
{
    document.writeln('navigator.' + i + ' = ' + navigator[i]);
}
document.write('</pre>');

My Firefox has this attribute:

navigator.language = en-US

... which should suit your needs.

artlung
A: 

Wow BipdelShark was fast! Here is a solution that I use to deal with most browsers:

<script type="text/javascript">
  var language = navigator.userLanguage || navigator.language;
  alert(language);
</script>
merkuro
No, you're not being dense. I have a en-US install of Firefox. From Tools.Options.Content.Languages, I deleted English/United States[en-US], and added Spanish[es]. I browse to a website and I can see Firefox sends the HTTP headerAccept-Language: esThe response returnsContent-Language: es-ESIf I use firebug to inspect window.navigator.language, it is "en-US" and my dojo application uses the incorrect language.Ironically, ie gets this right.
Ed
A: 

Sorry if I'm being dense, but I just 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 INSTALL of firefox it will work, but I shouldn't need to do that, right?

The useragent string still contains en-UK, too; but the accept-language on HTTP headers IS set correctly. Anyone know how to get to the correct setting?

Ian Grainger