-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CharacterDirectionOfLocale: Returns "ltr" for scripts without any character direction #90
Comments
@lianghai Do you have thoughts on what the correct behavior should be here? Does it make sense for all non-RTL scripts to return LTR, either if they don't have data or if they use some other script direction? |
I suppose this is about https://tc39.es/proposal-intl-locale-info/#sec-character-direction-of-locale? LTR is certainly the architectural default in practically all layout systems, but it’s weird for such a metadata API to use LTR to actually represent its internal “unknown”. ICU4X’s
You mean other directions like top-to-bottom? Those are either analyzed as LTR/RTL, or you need to expand the enum to actually include those cases – shouldn‘t be treated as “unknown” or let blindly fallback to LTR anyway. Note that some natively vertical scripts are LTR (eg, Mongolian) in the horizontal compromised layout, while other become RTL (eg, Old Uyghur). So it certainly doesn’t make sense to fold those all into LTR. And scripts like CJK have multiple native directions. Because of the complexity of properly modeling script directions (CSS’s model is a good reference), it’s reasonable to limit the architecture to LTR/RTL/unknown. |
TG2 discussion on 2025-02-06: https://github.com/tc39/ecma402/blob/main/meetings/notes-2025-02-06.md#localeinfo-text-directionality |
ICU4C's
uloc_isRightToLeft
doesn't seem to provide this information, but at least ICU4X'sLocaleDirectionality
has three possible return values:Direction::LeftToRight
Direction::RightToLeft
None
for scripts likeZzzz
orZyyy
.See also https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleDirectionality.html#method.get.
I'm not sure if there's an easy way to detect the unknown direction case in ICU4C, so I don't know if there's much support to support this case in the spec. But I guess we could at least document this case more clearly in the spec by adding an
<emu-note>
toCharacterDirectionOfLocale
to describe that"ltr"
is returned even when no direction is known.The text was updated successfully, but these errors were encountered: