Closed Bug 1719696 Opened 3 years ago Closed 3 years ago

Switch DateTimeFormat to use a component bag abstraction, rather than string skeletons

Categories

(Core :: Internationalization, task, P3)

task

Tracking

()

RESOLVED FIXED
94 Branch
Tracking Status
firefox94 --- fixed

People

(Reporter: gregtatum, Assigned: gregtatum)

References

Details

(Whiteboard: [i18n-unification])

Attachments

(9 files, 1 obsolete file)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

In ICU4X, the DateTimeFormat API will take a components bag + hour cycle preference as input, and then generate the formatted results. There is no skeleton or pattern API that is being exposed, as those are implementation details. This API can directly back ECMA-402's Intl.DateTimeFormat.

However, with ICU4C, the Intl.DateTimeFormat API is implemented using pattern and skeleton manipulation, which happens directly in the strings. This lets SpiderMonkey do things like manipulate the hour cycle to follow the spec. ICU4X does this automatically.

The work for this bug is to take SpiderMonkey's pattern manipulation code, and put it in a mozilla::intl component, and then expose a component bag API. This will allow for the eventual usage of ICU4X. This may or may not block performance testing of Intl.DateTimeFormat. Some investigation is required still to see if good results can be obtained without doing this refactoring.

Here you can see where the skeletons and patterns are stored internally:

https://searchfox.org/mozilla-central/rev/da25888c4495585c532640f0e5efad07b1037621/js/src/builtin/intl/DateTimeFormat.js#95-117

Here is code that ICU4X will be handling through a component bag:

https://searchfox.org/mozilla-central/rev/da25888c4495585c532640f0e5efad07b1037621/js/src/builtin/intl/DateTimeFormat.cpp#899-911

Blocks: 1715892
Assignee: nobody → gtatum

This patch will not compile. It naively copies over the hour cycle code
from SpiderMonkey into the unified components. In a following patch,
these will be modified to use only the unified types.

Depends on D123820

This patch will probably not compile on its own, but requires the SpiderMonkey
side as well. It aims at building a components bag interface that can be
then used in SpiderMonkey to back the ECMA 402 API.

Depends on D123821

This patch completes the move of pattern manipulation for
Intl.DateTimeFormat and places it in the unified API. If and when we
switch to ICU4X, the pattern manipulation code can be removed, as ICU4X
will handle that.

Depends on D123822

Whiteboard: [i18n-unification]
Attachment #9239405 - Attachment is obsolete: true
Pushed by gtatum@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/676f078fa705
Use ICUError in mozilla::intl::DateTimeFormat; r=platform-i18n-reviewers,dminor
https://hg.mozilla.org/integration/autoland/rev/60b2ef13fc96
Add a nicer assertion for checking the buffer contents; r=platform-i18n-reviewers,dminor
https://hg.mozilla.org/integration/autoland/rev/79a3304d03df
Naively move the hour cycle computations; r=anba,platform-i18n-reviewers,dminor
https://hg.mozilla.org/integration/autoland/rev/0b5d9fdd57a2
Create a components bag abstraction for mozilla::intl::DateTimeFormat; r=anba,platform-i18n-reviewers,dminor
https://hg.mozilla.org/integration/autoland/rev/b23f891ed375
Use a components bag for Intl.DateTimeFormat implementation; r=anba
https://hg.mozilla.org/integration/autoland/rev/268ea13a74e7
Add ICUPointer to DateTimePatternGenerator; r=platform-i18n-reviewers,dminor
https://hg.mozilla.org/integration/autoland/rev/9a05f50a92eb
Rework FillUTF8Buffer to FillBuffer; r=platform-i18n-reviewers,dminor
https://hg.mozilla.org/integration/autoland/rev/c36bd08f3752
Test the behavior DateTimeInterval formatting with skeletons; r=anba
https://hg.mozilla.org/integration/autoland/rev/f785d3c64243
Cache the original skeleton, and use it in DateIntervalFormat; r=anba,platform-i18n-reviewers,dminor
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: