aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/navigatorlanguage/language
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/navigatorlanguage/language
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/navigatorlanguage/language')
-rw-r--r--files/zh-cn/web/api/navigatorlanguage/language/index.html64
1 files changed, 64 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/navigatorlanguage/language/index.html b/files/zh-cn/web/api/navigatorlanguage/language/index.html
new file mode 100644
index 0000000000..24602dea56
--- /dev/null
+++ b/files/zh-cn/web/api/navigatorlanguage/language/index.html
@@ -0,0 +1,64 @@
+---
+title: NavigatorLanguage.language
+slug: Web/API/NavigatorLanguage/language
+tags:
+ - API
+ - NavigatorLanguage
+ - 参考
+ - 只读
+ - 多语言
+ - 属性
+ - 语言
+translation_of: Web/API/NavigatorLanguage/language
+---
+<div>{{APIRef("HTML DOM")}}</div>
+
+<p><strong><code>NavigatorLanguage.language</code></strong> 只读属性返回一个表示用户偏好语言的字符串,通常指浏览器 UI 的语言。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="brush: js"><em>let lang</em> = navigator.language;
+</pre>
+
+<h3 id="值">值</h3>
+
+<p>一个 {{domxref("DOMString")}}。<code>lang</code> 存储一个表示语言版本(在 <a href="http://www.ietf.org/rfc/bcp/bcp47.txt">BCP 47</a> 中定义)的字符串。合法的语言版本有 "zh-CN"、"en"、"en-US"、"fr"、"es-ES" 等。</p>
+
+<p>注意 macOS 和 iOS 平台上的 Safari(10.2 之前版本),国家代码为小写:"zh-cn"、"en-us"、"fr-fr" 等。</p>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: js">if ( window.navigator.language != 'zh-CN' ) {
+ doLangSelect(window.navigator.language);
+}
+</pre>
+
+<h2 id="标准">标准</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">标准</th>
+ <th scope="col">状态</th>
+ <th scope="col">备注</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('HTML WHATWG', '#dom-navigator-language', 'NavigatorLanguage: language')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>初次定义</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{Compat("api.NavigatorLanguage.language")}}</p>
+
+<h2 id="另请参阅">另请参阅</h2>
+
+<ul>
+ <li>{{domxref("NavigatorLanguage.languages", "navigator.languages")}}</li>
+ <li>{{domxref("navigator")}}</li>
+</ul>