File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -1628,3 +1628,17 @@ extern "C" {
1628
1628
#[ wasm_bindgen( static_method_of = Symbol , getter, structural, js_name = toStringTag) ]
1629
1629
pub fn to_string_tag ( ) -> Symbol ;
1630
1630
}
1631
+
1632
+ // Intl
1633
+ #[ wasm_bindgen]
1634
+ extern "C" {
1635
+ pub type Intl ;
1636
+
1637
+ /// The `Intl.getCanonicalLocales()` method returns an array containing
1638
+ /// the canonical locale names. Duplicates will be omitted and elements
1639
+ /// will be validated as structurally valid language tags.
1640
+ ///
1641
+ /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales
1642
+ #[ wasm_bindgen( static_method_of = Intl , js_name = getCanonicalLocales) ]
1643
+ pub fn get_canonical_locales ( s : & JsValue ) -> Array ;
1644
+ }
Original file line number Diff line number Diff line change
1
+ #![ allow( non_snake_case) ]
2
+
3
+ use project;
4
+
5
+ #[ test]
6
+ fn get_canonical_locales ( ) {
7
+ project ( )
8
+ . file ( "src/lib.rs" , r#"
9
+ #![feature(proc_macro, wasm_custom_section)]
10
+
11
+ extern crate wasm_bindgen;
12
+ use wasm_bindgen::prelude::*;
13
+ use wasm_bindgen::js;
14
+
15
+ #[wasm_bindgen]
16
+ pub fn get_canonical_locales(v: &JsValue) -> js::Array {
17
+ js::Intl::get_canonical_locales(v)
18
+ }
19
+ "# )
20
+ . file ( "test.js" , r#"
21
+ import * as assert from "assert";
22
+ import * as wasm from "./out";
23
+
24
+ export function test() {
25
+ let locales = ["EN-US", "Fr"];
26
+ let canonical_locales = wasm.get_canonical_locales(locales);
27
+ assert.deepStrictEqual(canonical_locales, ["en-US", "fr"]);
28
+
29
+ let single_locale = wasm.get_canonical_locales("EN-US");
30
+ assert.equal(single_locale, "en-US");
31
+ }
32
+ "# )
33
+ . test ( )
34
+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ mod Date;
10
10
mod Error ;
11
11
mod Function ;
12
12
mod Generator ;
13
+ mod Intl ;
13
14
mod JsString ;
14
15
mod Map ;
15
16
mod MapIterator ;
You can’t perform that action at this time.
0 commit comments