Skip to content

RegionPreference: Align with UTS 35? #1058

Description

@anba

RegionPreference doesn't seem to match UTS 35, see also https://unicode.org/reports/tr35/tr35.html#RegionOverride.

Issues:

  1. CanonicalUnicodeSubdivision calls CanonicalizeUnicodeLocaleId to replace region aliases. It's unclear if this is valid per UTS 35. For example in Processing LocaleIds, unicode_subdivision_id replaces subdivisions using <subdivisionAlias> without first canonicalizing the subdivision's unicode_region_subtag part.

Example:

js> new Intl.Locale("en-u-rg-826zzzz").getHourCycles()[0]
"h12"
js> new Intl.Locale("en-u-rg-gbzzzz").getHourCycles()[0]
"h23"

Per the current spec text, both calls should return "h23". (826 is the numeric region for GB.)

  1. Region Override defines that only "regular" and "unknown" regions are allowed and any other value should be ignored. Validity is checked against https://github.com/unicode-org/cldr/blob/main/common/validity/region.xml. I'm not sure if the "unknown" region should be accepted, though, because at least ICU4C seems to ignore it.

Examples:

js> new Intl.Locale("en-JP-u-rg-001zzzz").getCalendars()
["gregory", "japanese"]

The macro-region 001 has <calendarPreference> data, but the region override is ignored nonetheless.

js> new Intl.Locale("en-JP-u-rg-zzzzzz").getCalendars()
["gregory", "japanese"]
js> new Intl.Locale("ja-u-rg-zzzzzz-sd-thzzzz").getCalendars()
["buddhist", "gregory"]

Region override uses the "unknown" region ZZ, but it's ignored and instead the calendar preference from JP resp. TH is used.

js> new Intl.Locale("ja-u-sd-euzzzz").getCalendars()
["gregory", "japanese"]
js> new Intl.Locale("ja-u-sd-thzzzz").getCalendars()
["buddhist", "gregory"]

The subdivision using the macro-region EU is ignored and instead the calendar preference from JP (added through likely subtags) is used. When using a regular region (TH), the sd Unicode extension value is used.


Existing (browser) implementations directly call into ICU4C and don't implement any of the ECMA-402 specific operations, so changing the spec won't cause any web-compatibility issues. And ICU4C seems to ignore both region aliases and non-regular regions.


ICU4C is only buggy when using an empty Unicode extension value:

d8> new Intl.Locale("ja-u-rg").getCalendars()
["gregory", "islamic", "islamic-civil", "islamic-tbla"]

This probably happens because the empty string is treated as a shorthand for yes (either directly or by first replacing with the value true), and yes starts with the region code for YE (Yemen).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions