tor-browser

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

unicode-bcp47-locale-ids-region-mappings-complex.js (2844B)


      1 // |reftest| skip-if(!this.hasOwnProperty("Intl"))
      2 
      3 // CLDR contains region mappings where the replacement region depends on the
      4 // likely subtags from the language and script subtags.
      5 //
      6 // For example, the breakup of the Soviet Union ("SU") means that the region of
      7 // the Soviet Union ("SU") is replaced by Russia ("RU"), Armenia ("AM"), or
      8 // many others -- depending on the specified (or merely likely) language and
      9 // script subtags:
     10 //
     11 // <territoryAlias type="SU" replacement="RU AM AZ BY EE GE KZ KG LV LT MD TJ TM UA UZ" reason="deprecated"/>
     12 //
     13 // Armenia can be the preferred region when the language is "hy" (Armenian) or
     14 // the script is "Armn" (Armenian).
     15 //
     16 // <likelySubtag from="hy" to="hy_Armn_AM"/>
     17 // <likelySubtag from="und_Armn" to="hy_Armn_AM"/>
     18 assertEq(Intl.getCanonicalLocales("ru-SU")[0], "ru-RU");
     19 assertEq(Intl.getCanonicalLocales("en-SU")[0], "en-RU");
     20 assertEq(Intl.getCanonicalLocales("und-SU")[0], "und-RU");
     21 assertEq(Intl.getCanonicalLocales("und-Latn-SU")[0], "und-Latn-RU");
     22 assertEq(Intl.getCanonicalLocales("hy-SU")[0], "hy-AM");
     23 assertEq(Intl.getCanonicalLocales("und-Armn-SU")[0], "und-Armn-AM");
     24 
     25 // <territoryAlias type="CS" replacement="RS ME" reason="deprecated"/>
     26 //
     27 // The following likely-subtags entries contain "RS" and "ME":
     28 //
     29 // <likelySubtag from="sr" to="sr_Cyrl_RS"/>
     30 // <likelySubtag from="sr_ME" to="sr_Latn_ME"/>
     31 // <likelySubtag from="und_RS" to="sr_Cyrl_RS"/>
     32 // <likelySubtag from="und_ME" to="sr_Latn_ME"/>
     33 //
     34 // In this case there is no language/script combination (without a region
     35 // subtag) where "ME" is ever chosen, so the replacement is always "RS".
     36 assertEq(Intl.getCanonicalLocales("sr-CS")[0], "sr-RS");
     37 assertEq(Intl.getCanonicalLocales("sr-Latn-CS")[0], "sr-Latn-RS");
     38 assertEq(Intl.getCanonicalLocales("sr-Cyrl-CS")[0], "sr-Cyrl-RS");
     39 
     40 // The existing region in the source locale identifier is ignored when selecting
     41 // the likely replacement region. For example take "az-NT", which is Azerbaijani
     42 // spoken in the Neutral Zone. The replacement region for "NT" is either
     43 // "SA" (Saudi-Arabia) or "IQ" (Iraq), and there is also a likely subtags entry
     44 // for "az-IQ". But when only looking at the language subtag in "az-NT", "az" is
     45 // always resolved to "az-Latn-AZ", and because "AZ" is not in the list ["SA",
     46 // "IQ"], the final replacement region is the default for "NT", namely "SA".
     47 // That means "az-NT" will be canonicalised to "az-SA" and not "az-IQ", even
     48 // though the latter may be a more sensible candidate based on the actual usage
     49 // of the target locales.
     50 //
     51 // <territoryAlias type="NT" replacement="SA IQ" reason="deprecated"/>
     52 // <likelySubtag from="az_IQ" to="az_Arab_IQ"/>
     53 // <likelySubtag from="az" to="az_Latn_AZ"/>
     54 assertEq(Intl.getCanonicalLocales("az-NT")[0], "az-SA");
     55 
     56 if (typeof reportCompare === "function")
     57    reportCompare(true, true);