tc39 / proposal-intl-locale-info

An API to expose information of locale, such as week data ( first day of a week, weekend start, weekend end), hour cycle, measurement system, commonly used calendar, etc.
MIT License
56 stars 11 forks source link

CharacterDirectionOfLocale: Confusing reference to "characterOrder" #88

Open anba opened 2 months ago

anba commented 2 months ago

CharacterDirectionOfLocale references "characterOrder":

If the default general ordering of characters (characterOrder) within a line in locale is right-to-left, return "rtl".

"characterOrder" is defined in UTS 35 here: https://unicode.org/reports/tr35/tr35-general.html#Layout_Elements.

ICU provides two functions which are relevant here: uloc_getCharacterOrientation and uloc_isRightToLeft.

The "characterOrder" property can be retrieved through uloc_getCharacterOrientation, but the V8 implementation uses uloc_isRightToLeft for its CharacterDirectionOfLocale implementation. Both ICU functions can produce different results when non-default scripts are used. For example for "en-Arab", uloc_getCharacterOrientation returns ULOC_LAYOUT_LTR, whereas uloc_isRightToLeft returns true.

The spec should be written so that implementers know which ICU function has to be called. I think it's probably best to remove "characterOrder" from CharacterDirectionOfLocale, because it seems to hint into the wrong direction (uloc_getCharacterOrientation, but we actually want uloc_isRightToLeft, right?).