The NavigatorLanguage.language
read-only property returns a string representing the preferred language of the user, usually the language of the browser UI.
var lang = navigator.language
A DOMString
. lang
stores a string representing the language version as defined in BCP 47. Examples of valid language codes include "en", "en-US", "fr", "fr-FR", "es-ES", etc.
Note that in Safari on macOS and iOS prior to 10.2, the country code returned is lowercase: "en-us", "fr-fr" etc.
if (window.navigator.language != 'en') { doLangSelect(window.navigator.language); }
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'NavigatorLanguage: language' in that specification. | Living Standard | Initial definition |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes
|
Yes | 1
|
11
|
Yes | Yes |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes
|
Yes
|
Yes | 4 | Yes | Yes | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/navigatorLanguage/language