Closed Bug 1639515 Opened 4 years ago Closed 3 years ago

Investigate replacing mozIntl.getDisplayNames with Intl.DisplayNames

Categories

(Core :: Internationalization, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
94 Branch
Tracking Status
firefox94 --- fixed

People

(Reporter: anba, Assigned: anba)

References

Details

Attachments

(6 files, 2 obsolete files)

Support for date-time types was removed from the Intl.DisplayNames proposal (https://github.com/tc39/proposal-intl-displaynames/pull/63), but will reappear at some later stage. The Intl.DisplayNames implementation which landed in bug 1557727 has an option to re-enable date-time types, though. We could use this enhanced Intl.DisplayNames version to replace the current callers to the Intl.getDisplayNames function (which is also non-standard).

This will result in a slight change of behaviour, because Intl.getDisplayNames' "short" style is mapped to CLDR's "abbreviated" style, whereas Intl.DisplayNames' "short" style is mapped to CLDR's "short" style.

For example the display name for Sunday will change as follows:

Locale CLDR abbreviated CLDR short
English Sun Su
Polish niedz. nie
German So So.
French dim. di
Spanish dom. DO

Expose Intl.DisplayNames to mozIntl. The exposed Intl.DisplayNames version
supports date-time types, which have been removed from the spec proposal, but
may be re-enabled at some point in the future.

The existing getDisplayNames WebIDL function had to be renamed, because WebIDL
doesn't allow specify an attribute named DisplayNames and a separate function
called getDisplayNames.

Drive-by change:

  • Removed an out-dated comment in "mozIMozIntlHelper.idl" which mentioned calling
    addDateTimeFormatConstructor twice throws an error.

Update callers to the previous mozIntl.getDisplayNames function to use
mozIntl.DisplayNames.

There's a slight change in behaviour:
The "short" style for mozIntl.getDisplayNames was mapped to what CLDR calls
the "abbreviated" style, whereas mozIntl.DisplayNames's "short" style is
mapped to CLDR's "short" style. (UDAT_STANDALONE_SHORT_WEEKDAYS uses
CLDR's "abbreviated" style, whereas UDAT_STANDALONE_SHORTER_WEEKDAYS uses
CLDR's "short" style.)
That means for example Polish "niedziela" (Sunday) is now displayed as "nie",
but was previously displayed as "niedz.".

Depends on D76114

Update the documention to mention Intl.DisplayNames instead of
Intl.getDisplayNames.

Depends on D76115

Rewrite mozIntl.getDisplayNames to use mozIntl.DisplayNames, so we can use
it for intlUtils.getDisplayNames, which doesn't have direct access to
mozIntl.DisplayNames.

This change will allow to remove getDisplayNames from SpiderMonkey in a later
patch in this stack.

Depends on D76116

This function is no longer needed after part 4.

Depends on D76117

Drive-by change:

  • Reorder constructors to be in alphabetical order.

Depends on D76118

Add Intl.Locale to mozIntl.Locale, so all constructor functions from Intl
are also directly available on mozIntl.

Also update some places to use Intl.Locale instead of performing manual
language tag parsing. (Intl.Locale doesn't provide an accessor for
variants subtags, so a bit of manual parsing is still necessary.)

Depends on D76119

Added some draft patches to show how this could be implemented.

Severity: -- → S3

Those patches look great! Thank you so much Anba!

Added some draft patches to show how this could be implemented.

I think you did a bit more than that ;) What's missing to make them ready to review?

Flags: needinfo?(andrebargull)

(In reply to Zibi Braniecki [:zbraniecki][:gandalf] from comment #9)

What's missing to make them ready to review?

  • Getting approval that using CLDR "short" instead of "abbreviated" style is okay for the date-time picker element (<input type="date">). The change is also visible for the about:protections page, but I guess that one isn't as user-visible as the date-time picker (, because I assume not that many users visit about:protections.)
    • FWIW Chrome already seems to use CLDR "short" style for their date-time picker element.
  • And we want to make sure that supporting date-time display names is still on track for the Intl.DisplayNames proposal. I think that's still the plan, but you probably know more about the current state of the proposal than me. :-)
Flags: needinfo?(andrebargull)

Getting approval that using CLDR "short" instead of "abbreviated" style is okay for the date-time picker element (<input type="date">). The change is also visible for the about:protections page, but I guess that one isn't as user-visible as the date-time picker (, because I assume not that many users visit about:protections.)

Yes. I filed https://github.com/tc39/proposal-intl-displaynames/issues/74 and let's see what the community says.
I prefer abbreviated for English, but it's not a strong opinion.

If ECMA402 will not want to support it, we still may want to consider adding it for Mozilla-only use or switch to short.

And we want to make sure that supporting date-time display names is still on track for the Intl.DisplayNames proposal. I think that's still the plan, but you probably know more about the current state of the proposal than me. :-)

Filed https://github.com/tc39/proposal-intl-displaynames/issues/75

I'd also like to consider, in case ECMA402 cannot commit, to expose those two as Mozilla-only. We know we need to use them, and extending Intl API for Mozilla use seems easier and lower overhead than implementing separate ICU callsites for mozIntl.

No longer blocks: 1635561
Depends on: 1635561
Priority: -- → P3
Attachment #9150413 - Attachment is obsolete: true
Attachment #9150412 - Attachment is obsolete: true

As a non-standard extension, add the "abbreviated" style to be able to select
CLDR's abbreviated format. This style is used by the DateTimePicker component
for weekdays.

Assignee: nobody → andrebargull
Status: NEW → ASSIGNED
Attachment #9150407 - Attachment description: Bug 1639515 - Part 1: Add mozIntl.DisplayNames. r=gandalf! → Bug 1639515 - Part 2: Add mozIntl.DisplayNames. r=#platform-i18n-reviewers!
Attachment #9150408 - Attachment description: Bug 1639515 - Part 2: Port mozIntl.getDisplayNames users to mozIntl.DisplayNames. r=gandalf! → Bug 1639515 - Part 3: Port mozIntl.getDisplayNames users to mozIntl.DisplayNames. r=#platform-i18n-reviewers!
Attachment #9150409 - Attachment description: Bug 1639515 - Part 3: Update docs to point to Intl.DisplayNames. r=gandalf! → Bug 1639515 - Part 4: Update docs to point to Intl.DisplayNames. r=#platform-i18n-reviewers!
Attachment #9150410 - Attachment description: Bug 1639515 - Part 4: Rewrite mozIntl.getDisplayNames to work in terms of mozIntl.DisplayNames. r=gandalf! → Bug 1639515 - Part 5: Rewrite mozIntl.getDisplayNames to work in terms of mozIntl.DisplayNames. r=#platform-i18n-reviewers!
Attachment #9150411 - Attachment description: Bug 1639515 - Part 5: Remove no longer used Intl.getDisplayNames. r=gandalf! → Bug 1639515 - Part 6: Remove no longer used Intl.getDisplayNames. r=#platform-i18n-reviewers!
Pushed by andre.bargull@gmail.com: https://hg.mozilla.org/integration/autoland/rev/970826244d07 Part 1: Add non-standard "abbreviated" style to MozDisplayNames. r=platform-i18n-reviewers,gregtatum https://hg.mozilla.org/integration/autoland/rev/3681111b7ed3 Part 2: Add mozIntl.DisplayNames. r=platform-i18n-reviewers,gregtatum https://hg.mozilla.org/integration/autoland/rev/5a08d3b17fa7 Part 3: Port mozIntl.getDisplayNames users to mozIntl.DisplayNames. r=platform-i18n-reviewers,gregtatum https://hg.mozilla.org/integration/autoland/rev/6919213b03f7 Part 4: Update docs to point to Intl.DisplayNames. r=platform-i18n-reviewers,gregtatum https://hg.mozilla.org/integration/autoland/rev/6d361f92b27e Part 5: Rewrite mozIntl.getDisplayNames to work in terms of mozIntl.DisplayNames. r=platform-i18n-reviewers,gregtatum,webidl,emilio https://hg.mozilla.org/integration/autoland/rev/eaff696ed6a6 Part 6: Remove no longer used Intl.getDisplayNames. r=platform-i18n-reviewers,gregtatum
Flags: needinfo?(andrebargull)
Pushed by andre.bargull@gmail.com: https://hg.mozilla.org/integration/autoland/rev/7f387112b4a5 Part 1: Add non-standard "abbreviated" style to MozDisplayNames. r=platform-i18n-reviewers,gregtatum https://hg.mozilla.org/integration/autoland/rev/d8caab702d3f Part 2: Add mozIntl.DisplayNames. r=platform-i18n-reviewers,gregtatum https://hg.mozilla.org/integration/autoland/rev/1670460a5435 Part 3: Port mozIntl.getDisplayNames users to mozIntl.DisplayNames. r=platform-i18n-reviewers,gregtatum https://hg.mozilla.org/integration/autoland/rev/f5b3ca80c125 Part 4: Update docs to point to Intl.DisplayNames. r=platform-i18n-reviewers,gregtatum https://hg.mozilla.org/integration/autoland/rev/96418f6e99c7 Part 5: Rewrite mozIntl.getDisplayNames to work in terms of mozIntl.DisplayNames. r=platform-i18n-reviewers,gregtatum,webidl,emilio https://hg.mozilla.org/integration/autoland/rev/18fdaf3f7de5 Part 6: Remove no longer used Intl.getDisplayNames. r=platform-i18n-reviewers,gregtatum
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: