i18n icon indicating copy to clipboard operation
i18n copied to clipboard

Mismatch between ICU4X and ECMA402 for `package:intl4x`

Open mosuem opened this issue 1 year ago • 4 comments

This issue is for collecting mismatches between ICU4X and ECMA402.

cc @robertbastian @sffc @manishearth

Datetime

Defaults:

Intl(locale: const Locale(language: 'en', region: 'US'))
              .datetimeFormat()
              .format(DateTime.utc(2012, 12, 20, 3, 0, 0))

prints 12/20/2012 - this doesn't correspond to any DateLength for ICU4X.

Timezones:

Intl(locale: const Locale(language: 'en', region: 'US'))
            .datetimeFormat(DateTimeFormatOptions(
              timeZone: 'America/Los_Angeles',
              timeZoneName: TimeZoneName.long,
            ))
            .format(date)

prints 12/16/2021, Pacific Standard Time - formatting a date with a timezone is not possible in ICU4X.

More complex patterns:

Intl(locale: const Locale(language: 'fr'))
              .datetimeFormat(const DateTimeFormatOptions(
                hour: TimeStyle.numeric,
                clockstyle: ClockStyle(
                  is12Hour: true,
                  startAtZero: false,
                ),
                dayPeriod: DayPeriod.long,
                timeZone: 'UTC',
              ))
              .format(date)

prints 4 du matin - formatting complex patterns in not possible in ICU4X.

Calendar:

islamic has no direct corresponding entry in AnyCalendarKind.

Number formatting

Dart needs some logic to map the API settings to each other, due to the very different APIs between ICU4X and ECMA402. See https://github.com/dart-lang/i18n/blob/3c7f76bedffde2f9408b2b40c22bca6976ddc5ee/pkgs/intl4x/lib/src/number_format/number_format_4x.dart#L46. Also missing some functionality such as percentage, scientific, or unit formatting, see https://github.com/unicode-org/icu4x/issues/275.

Plural rules

Only ordinal, cardinal supported, but no number formatting options, see also https://github.com/tc39/ecma402/issues/365.

Display names

Missing support for DateTime, Calendar, Currency, and Script display.

Also, for display names of languages, zh-Hant seems to resolve to zh_Hant-long for ICU4X, but not ECMA, see https://st.unicode.org/cldr-apps/v#/en/Languages_A_D/32a57b96452f2198 and https://github.com/dart-lang/i18n/actions/runs/7888128898/job/21524894392?pr=800.

mosuem avatar Feb 06 '24 15:02 mosuem

@sffc you're the most up to date on ECMA402 coverage: do you know if we have issues for most of these? Are any of these unexpected (they seem to be known gaps)

Manishearth avatar Feb 09 '24 17:02 Manishearth

These are mostly the set of known ECMA-402 compat issues and they are mostly resourced. See the master spreadsheet:

https://docs.google.com/spreadsheets/d/1rdH5_LqiMvFJM9pj3AEFigeCYdH9Y2Lpw7-MJ23T73A/edit#gid=0

One thing:

islamic has no direct corresponding entry in AnyCalendarKind.

We support all 4 flavors of islamic calendar. -u-ca-islamic corresponds to AnyCalendarKind::IslamicObservational.

sffc avatar Feb 09 '24 20:02 sffc

-u-ca-islamic corresponds to AnyCalendarKind::IslamicObservational

We should document this better.

There are 5 islamic calendars in CLDR: https://github.com/unicode-org/cldr/blob/main/common/bcp47/calendar.xml#L22-L26. The names don't match up directly, which one is missing?

robertbastian avatar Feb 12 '24 10:02 robertbastian

RGSA, which is is also missing in ICU but ICU lies about it

Manishearth avatar Feb 12 '24 15:02 Manishearth