tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

unicode-bcp47-locale-ids-legacy.js (1266B)


      1 // |reftest| skip-if(!this.hasOwnProperty("Intl"))
      2 
      3 // Unicode BCP 47 locale identifiers don't support irregular legacy tags.
      4 var irregularLegacy = [
      5    "en-gb-oed",
      6    "i-ami",
      7    "i-bnn",
      8    "i-default",
      9    "i-enochian",
     10    "i-hak",
     11    "i-klingon",
     12    "i-lux",
     13    "i-mingo",
     14    "i-navajo",
     15    "i-pwn",
     16    "i-tao",
     17    "i-tay",
     18    "i-tsu",
     19    "sgn-be-fr",
     20    "sgn-be-nl",
     21    "sgn-ch-de",
     22 ];
     23 
     24 // Unicode BCP 47 locale identifiers don't support regular legacy tags
     25 // which contain an extlang-like subtag.
     26 var regularLegacyWithExtlangLike = [
     27    "no-bok",
     28    "no-nyn",
     29    "zh-min",
     30    "zh-min-nan",
     31 ];
     32 
     33 // Unicode BCP 47 locale identifiers do support regular legacy tags
     34 // which contain a variant-like subtag.
     35 var regularLegacyWithVariantLike = {
     36    "art-lojban": "jbo",
     37    "cel-gaulish": "xtg",
     38    "zh-guoyu": "zh",
     39    "zh-hakka": "hak",
     40    "zh-xiang": "hsn",
     41 };
     42 
     43 for (let locale of [...irregularLegacy, ...regularLegacyWithExtlangLike]) {
     44    assertThrowsInstanceOf(() => Intl.getCanonicalLocales(locale), RangeError);
     45 }
     46 
     47 for (let [locale, canonical] of Object.entries(regularLegacyWithVariantLike)) {
     48    assertEq(Intl.getCanonicalLocales(locale)[0], canonical);
     49 }
     50 
     51 if (typeof reportCompare === "function")
     52    reportCompare(true, true);