--- title: NavigatorLanguage.language slug: Web/API/NavigatorLanguage/language translation_of: Web/API/NavigatorLanguage/language ---
{{APIRef("HTML DOM")}}

 

NavigatorLanguage.language 읽기 전용 속성은 사용자의 기본 언어 (일반적으로 브라우저 UI의 언어)를 나타내는 문자열을 반환합니다.

Syntax

var lang = navigator.language

Value

A {{domxref("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.

Example

if (window.navigator.language != 'en') {
  doLangSelect(window.navigator.language);
}

Specifications

Specification Status Comment
{{ SpecName('HTML5.1', '#dom-navigator-language', 'NavigatorLanguage.language') }} {{ Spec2('HTML5.1') }} Initial definition

Browser compatibility

{{CompatibilityTable}}

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatVersionUnknown}}[1] {{CompatVersionUnknown}} {{CompatGeckoDesktop("1.0")}}[2]
{{CompatGeckoDesktop("5.0")}}[3]
11.0[4] {{CompatVersionUnknown}} {{CompatVersionUnknown}}
on {{domxref("WorkerNavigator")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatGeckoDesktop("35")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
Feature Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatGeckoMobile(1.0)}} {{CompatNo}}[4] {{CompatVersionUnknown}} {{CompatVersionUnknown}}
on {{domxref("WorkerNavigator")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatGeckoDesktop("35")}} {{CompatNo}} {{CompatUnknown}} {{CompatUnknown}}

[1] Returns the browser UI language, not the value of the Accept-Language HTTP header.

[2] Prior to Gecko 2.0 {{geckoRelease("2.0")}}, this property's value was also part of the user agent string, as reported by {{domxref("window.navigator.userAgent", "navigator.userAgent")}}.

[3] Starting in Gecko 5.0 {{geckoRelease("5.0")}}, this property's value is based on the value of the Accept-Language HTTP header.

[4] Closest available (non-standard) properties are userLanguage and browserLanguage.

See also