2

How javascript to get the OS system language in Chrome, not the browser language setting. I mean if your check "navigator.language" in debugger, what it shows is the browser language. However, it you change the language in the control pannel-->Clock,Language,and Region -->Region and Language-->Format , to, for example Romansh(Switzerland), the "navigator.language" will not reflect it.

By the way, if you check the "navigator.language" in IE11, it will show "rm-CH" in above example.

Thank you in advance for your clue.

user2029505
  • 529
  • 1
  • 4
  • 12
  • 1
    possible duplicate of [JavaScript for detecting browser language preference](http://stackoverflow.com/questions/1043339/javascript-for-detecting-browser-language-preference) – teynon Aug 07 '15 at 16:36
  • That post is related to the browser language preference, not the language setting in control panel->Clock,Language,and Region->Region and Language – user2029505 Aug 18 '15 at 14:37

1 Answers1

1
 var version= navigator.appVersion;
 var agent= navigator.userAgent;
 var language = window.navigator.language;

 var browserName  = navigator.appName;
 var fullVersion  = ''+parseFloat(navigator.appVersion); 
 var majorVersion = parseInt(navigator.appVersion,10);

 alert(version);
 alert(agent);
 alert(language);
 alert(browserName);
 alert(fullVersion);
  • This will get the language setting of browser, for example "en-US", not the language setting in the control panel. – user2029505 Aug 07 '15 at 16:53
  • I would think that if someone has their Chrome language settings set a certain way, they want to view webpages in that language, no? Not all OS's will even have a perfectly similar control panel to Windows anyway. – Katana314 Aug 07 '15 at 17:22
  • @Katana314 My browser's language is 'en-us' but my O/S country is Australia. Not all users configure their browser language but the O/S is always configured. Australia display date formats different to the US. If my locale was detected from the browser the dates would display wrong for me. – Kellie Nov 09 '21 at 06:30