Navigator: language プロパティ
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Navigator.language
は読み取り専用プロパティで、ユーザーの言語を表す文字列を返します。普通、ブラウザー UI の言語が返されます。
値
文字列で、 RFC 5646: Tags for Identifying Languages (also known as BCP 47) で定義された言語バージョンを表します。例えば、"en"、"en-US"、"fr"、"fr-FR"、"es-ES" などが含まれます。
iOS 10.2 以前の Safari では、国コードは "en-us"、"fr-fr" のように小文字で返されます。
例
js
if (/^en\b/.test(navigator.language)) {
doLangSelect(window.navigator.language);
}
仕様書
Specification |
---|
HTML # dom-navigator-language-dev |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
language |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.