From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../intl/getcanonicallocales/index.html | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 files/zh-cn/web/javascript/reference/global_objects/intl/getcanonicallocales/index.html (limited to 'files/zh-cn/web/javascript/reference/global_objects/intl/getcanonicallocales/index.html') 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 +--- +
{{JSRef}}
+ +

Intl.getCanonicalLocales() 方法返回一个数组,数组包含规范的区域语言代码,重复的元素将会被去除,每一个元素都会被验证为格式有效的区域语言代码。

+ +
{{EmbedInteractiveExample("pages/js/intl-getcanonicallocales.html")}}
+ + + +

Syntax

+ +
Intl.getCanonicalLocales(locales)
+ +

参数

+ +
+
locales
+
想要规范化的字符串数组。
+
+ +

Return value

+ +

一个包含规范区域语言代码的数组。

+ +

例子

+ +
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
+
+ +

规范

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES Int Draft', '#sec-intl.getcanonicallocales', 'Intl.getCanonicalLocales')}}{{Spec2('ES Int Draft')}}Initial definition
+ +

浏览器兼容

+ +
+ + +

{{Compat("javascript.builtins.Intl.getCanonicalLocales")}}

+
+ +

参见

+ + -- cgit v1.2.3-54-g00ecf