diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/javascript/reference/global_objects/intl/getcanonicallocales/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/intl/getcanonicallocales/index.html')
-rw-r--r-- | files/zh-cn/web/javascript/reference/global_objects/intl/getcanonicallocales/index.html | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/intl/getcanonicallocales/index.html b/files/zh-cn/web/javascript/reference/global_objects/intl/getcanonicallocales/index.html new file mode 100644 index 0000000000..78ee477634 --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/intl/getcanonicallocales/index.html @@ -0,0 +1,72 @@ +--- +title: Intl.getCanonicalLocales() +slug: Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales +tags: + - 区域语言代码 + - 去重 +translation_of: Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales +--- +<div>{{JSRef}}</div> + +<p><strong><code>Intl.getCanonicalLocales()</code></strong> 方法返回一个数组,数组包含规范的区域语言代码,重复的元素将会被去除,每一个元素都会被验证为格式有效的区域语言代码。</p> + +<div>{{EmbedInteractiveExample("pages/js/intl-getcanonicallocales.html")}}</div> + + + +<h2 id="Syntax">Syntax</h2> + +<pre class="syntaxbox">Intl.getCanonicalLocales(locales)</pre> + +<h3 id="参数">参数</h3> + +<dl> + <dt><code>locales</code></dt> + <dd>想要规范化的字符串数组。</dd> +</dl> + +<h3 id="Return_value">Return value</h3> + +<p>一个包含规范区域语言代码的数组。</p> + +<h2 id="例子">例子</h2> + +<pre class="brush: js">Intl.getCanonicalLocales('EN-US'); // ["en-US"] +Intl.getCanonicalLocales(['EN-US', 'Fr']); // ["en-US", "fr"] + +Intl.getCanonicalLocales('EN_US'); +// RangeError:'EN_US' is not a structurally valid language tag +</pre> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName('ES Int Draft', '#sec-intl.getcanonicallocales', 'Intl.getCanonicalLocales')}}</td> + <td>{{Spec2('ES Int Draft')}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容">浏览器兼容</h2> + +<div> + + +<p>{{Compat("javascript.builtins.Intl.getCanonicalLocales")}}</p> +</div> + +<h2 id="参见">参见</h2> + +<ul> + <li>{{jsxref("NumberFormat.supportedLocalesOf", "Intl.NumberFormat.supportedLocalesOf()")}}</li> + <li>{{jsxref("DateTimeFormat.supportedLocalesOf", "Intl.DateTimeFormat.supportedLocalesOf()")}}</li> + <li>{{jsxref("Collator.supportedLocalesOf", "Intl.Collator.supportedLocalesOf()")}}</li> +</ul> |