Closed Bug 1693576 Opened 5 years ago Closed 2 months ago

Implement Intl.LocaleInfo

Categories

(Core :: JavaScript: Internationalization API, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
152 Branch
Size Estimate S
Tracking Status
firefox152 --- fixed

People

(Reporter: yulia, Assigned: anba)

References

(Blocks 2 open bugs)

Details

(5 keywords, Whiteboard: [DocArea=JS][platform-feature])

User Story

platform-scheduled:2025-06-30
web-feature:intl-locale-info
user-impact-score:80
webcompat-risk:moderate

Attachments

(23 files, 10 obsolete files)

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
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
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

Currently at stage 2

Component: JavaScript Engine → JavaScript: Internationalization API
No longer depends on: 1693575

Only a draft patch for now until the various issues I've reported at https://github.com/tc39/proposal-intl-locale-info/issues have been resolved resp. clarified.

Assignee: nobody → andrebargull
Status: NEW → ASSIGNED
Attachment #9222188 - Attachment description: Bug 1693576: Implement Intl Locale Info API proposal. → Bug 1693576 - Part 1: Add CompareStrings overload for linear strings. r=yulia!

LocaleObject doesn't use a reserved slot to store the [[Calendar]] internal
slot, so we have to extract any Unicode "ca" extension sequences directly
from the locale identifier via GetUnicodeExtension().

If no "ca" Unicode keyword is present in the locale, we're calling into ICU
to retrieve all commonly used calendars of the locale (via
ucal_getKeywordValuesForLocale()).

ICU has certain internal limits on how large the input locale can be, so to make
sure we don't run into these limits, the LocaleLSR helper class extracts the
language, script, and region subtags of a locale. The LSR-subtags are guaranteed
to fit into the ICU limits.

Depends on D115223

Similar to part 2, but this time for collations instead of calendars.

Depends on D116467

Unfortunately support for hour cycles is more convoluted, because ICU doesn't
have public APIs to get the complete set of supported hour cycles for a locale:

There is udatpg_getDefaultHourCycle(), but that function only returns the
default hour cycle, but not any additionally allowed hour cycles. So we have to
do it the hard way and directly read ICU resource bundles to get the data we
need for this feature.

Depends on D116468

There is no way to figure out which numbering systems are commonly used by a
specific locale (because this data isn't even recorded in CLDR), so we can
only return the default numbering system.

Depends on D116469

Time zone names are canonicalised and sorted alphabetically. Canonicalisation
has the usual problem that ICU uses CLDR time zone canonicalisation, whereas
the spec requires IANA canonicalisation, so we have to perform some extra
steps here.

Depends on D116470

Depends on D116471

This code is based on the existing code in js::intl_GetCalendarInfo() with
the exception of gracefully handling UCAL_WEEKEND_{ONSET,CEASE} instead of
throwing an error.

Depends on D116472

Patches split for review, but I'm still waiting for the open spec issues to be resolved before actually requesting review.

Attachment #9222188 - Attachment is obsolete: true

Pass through the "commonlyUsed" parameter to ICU to be able to filter any
uncommon keyword values.

ICU's public API only provides a function to return the preferred hour cycle
(udatpg_getDefaultHourCycle()), whereas for Intl.Locale we want to be able
to determine all allowed hour cycles. So we have to do it the hard way and
directly read ICU resource bundles to get the data we need for this feature.

Depends on D125570

Use the new NumberingSystem class to replace UNumberingSystem in SpiderMonkey.

Depends on D125572

Time zone functions being part of UCalendar is an internal implementation
detail of ICU4C. For the public unified Intl API we should rather follow
Temporal (or ICU4C's C++ API) and have a separate TimeZone class.

The files were moved using hg cp to preserve the file history.

Depends on D125573

  • TimeZone objects can be created with any time zone identifier, so the "Default"
    part in the name isn't correct.
  • The "TimeZone" part is no longer needed, now that there's a distinct class for
    TimeZone objects.

Therefore let's rename GetDefaultTimeZoneOffsetMs() to GetRawOffsetMs().

Depends on D125574

The filter type is UCAL_ZONE_TYPE_ANY to ensure all possible time zones are
returned, and not just CLDR canonical time zones. (CLDR canonical time zones
are different from IANA canonical time zones.)

Depends on D125575

Currently only provides a single method to retrieve the character orientation.

The default constructor was deleted because all methods are static.

Depends on D125576

The last addition for the "Intl Locale Info API" proposal.

Depends on D125577

Move CreateArrayFromList to intl/CommonFunctions so later patches in this
patch stack can use it.

Attachment #9224427 - Attachment description: Bug 1693576 - Part 2: Implement Intl.Locale.prototype.calendars. r=yulia! → WIP: Bug 1693576 - Part 11: Implement Intl.Locale.prototype.calendars.
Attachment #9224428 - Attachment description: Bug 1693576 - Part 3: Implement Intl.Locale.prototype.collations. r=yulia! → WIP: Bug 1693576 - Part 12: Implement Intl.Locale.prototype.collations.
Attachment #9224430 - Attachment description: Bug 1693576 - Part 4: Implement Intl.Locale.prototype.hourCycles. r=yulia! → WIP: Bug 1693576 - Part 13: Implement Intl.Locale.prototype.hourCycles.
Attachment #9224431 - Attachment description: Bug 1693576 - Part 5: Implement Intl.Locale.prototype.numberingSystems. r=yulia! → WIP: Bug 1693576 - Part 14: Implement Intl.Locale.prototype.numberingSystems.
Attachment #9224432 - Attachment description: Bug 1693576 - Part 6: Implement Intl.Locale.prototype.timeZones. r=yulia! → WIP: Bug 1693576 - Part 15: Implement Intl.Locale.prototype.timeZones.
Attachment #9224433 - Attachment description: Bug 1693576 - Part 7: Implement Intl.Locale.prototype.textInfo. r=yulia! → WIP: Bug 1693576 - Part 16: Implement Intl.Locale.prototype.textInfo.
Attachment #9224434 - Attachment description: Bug 1693576 - Part 8: Implement Intl.Locale.prototype.weekInfo. r=yulia! → WIP: Bug 1693576 - Part 17: Implement Intl.Locale.prototype.weekInfo.
Blocks: 1730779
Attachment #9241169 - Attachment description: Bug 1693576 - Part 9: Add a method to retrieve week day information to Calendar. r=#platform-i18n-reviewers! → Bug 1693576 - Part 8: Add a method to retrieve week day information to Calendar. r=#platform-i18n-reviewers!
Keywords: leave-open
Pushed by andre.bargull@gmail.com: https://hg.mozilla.org/integration/autoland/rev/5518e046d03a Part 1: Add "commonlyUsed" to Calendar and Collator. r=platform-i18n-reviewers,gregtatum https://hg.mozilla.org/integration/autoland/rev/4fb2491acf41 Part 2: Add DateTimeFormat::GetAllowedHourCycles(). r=platform-i18n-reviewers,gregtatum https://hg.mozilla.org/integration/autoland/rev/91c7f73689b3 Part 3: Add NumberingSystem class to the unified Intl API component. r=platform-i18n-reviewers,gregtatum https://hg.mozilla.org/integration/autoland/rev/a56309fdebdd Part 4: Switch intl_numberingSystem to use mozilla::intl::NumberingSystem. r=platform-i18n-reviewers,gregtatum https://hg.mozilla.org/integration/autoland/rev/2478cae35f36 Part 5: Move time zone functions from mozilla::Calendar into mozilla::TimeZone. r=platform-i18n-reviewers,gregtatum https://hg.mozilla.org/integration/autoland/rev/afb87d21b97b Part 6: Rename GetDefaultTimeZoneOffsetMs() to GetRawOffsetMs(). r=platform-i18n-reviewers,gregtatum https://hg.mozilla.org/integration/autoland/rev/3e6b7914038c Part 7: Add method to enumerate over all time zones used in a region. r=platform-i18n-reviewers,gregtatum https://hg.mozilla.org/integration/autoland/rev/5c5ea857c3d9 Part 8: Add a method to retrieve week day information to Calendar. r=platform-i18n-reviewers,gregtatum
Blocks: 1750781

The leave-open keyword is there and there is no activity for 6 months.
:sdetar, maybe it's time to close this bug?
For more information, please visit auto_nag documentation.

Flags: needinfo?(sdetar)

The spec for the proposal didn't progress in the last months.

Flags: needinfo?(sdetar)

Hi Anba, Frank is hoping to advance this to stage 4 in the near term, and he is wondering if you are waiting on any information from him prior to you being able to continue with the implementation. Thanks!

Flags: needinfo?(andrebargull)

Issues like https://github.com/tc39/proposal-intl-locale-info/issues/30 still need to be resolved. The last comment seems to be confused about the meaning of [[RelevantExtensionKeys]] for Intl.Locale: While it is true that Intl.Locale has a [[RelevantExtensionKeys]] internal slot, Intl.Locale isn't an Intl service constructor, so Intl.Locale.[[RelevantExtensionKeys]] doesn't imply that Intl.Locale instances have to care about any extension keys.

Flags: needinfo?(andrebargull)
Duplicate of this bug: 1810936
Duplicate of this bug: 1837552
Whiteboard: [DocArea=JS] → [DocArea=JS] webcompat:risk-moderate
User Story: (updated)
Duplicate of this bug: 1937867

Issues like https://github.com/tc39/proposal-intl-locale-info/issues/30 still need to be resolved.

It looks like this issue was resolved on 2024-11-24. Are there any other blockers?

This implements the accessor property textInfo, but keep in mind it's now a method called getTextInfo to prevent the situation of locale.textInfo === locale.textInfo returning false: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo

User Story: (updated)
Size Estimate: --- → S

I think we're waiting on https://github.com/tc39/proposal-intl-locale-info/issues/76 before we can finish this off.

User Story: (updated)
User Story: (updated)
Whiteboard: [DocArea=JS] webcompat:risk-moderate → [DocArea=JS][platform-feature][webcompat:risk-moderate]

(In reply to Dan Minor [:dminor] from comment #33)

I think we're waiting on https://github.com/tc39/proposal-intl-locale-info/issues/76 before we can finish this off.

This seems resolved, are there still any blockers?

Hi Anba, are you planning on finishing this off, or would you like me to have a look? It's no problem either way, just would like to know for planning purposes. Thanks :)

Flags: needinfo?(andrebargull)

I was planing to look into this again next month. There are still some other Intl and Temporal related things I'd like to tackle first.

Flags: needinfo?(andrebargull)

Great, thank you for working on this :)

Depends on: 2034149
Attachment #9241168 - Attachment is obsolete: true
Attachment #9241171 - Attachment is obsolete: true
Attachment #9224427 - Attachment is obsolete: true
Attachment #9224428 - Attachment is obsolete: true
Attachment #9224430 - Attachment is obsolete: true
Attachment #9224431 - Attachment is obsolete: true
Attachment #9224432 - Attachment is obsolete: true
Attachment #9224433 - Attachment is obsolete: true
Attachment #9224434 - Attachment is obsolete: true

New Intl.Locale methods will return arrays and objects, so we now need to
handle these types here.

For now we only need to access LocaleDirectionality from the icu_locale crate.

ICU4C doesn't have information for additional numbering systems per locale, so
getNumberingSystems will always return an array with a single element.

Attachment #9572905 - Attachment description: Bug 1693576 - Part 3: Implement Intl.Locale firstDayOfWeek option and accessor. r=dminor! → Bug 1693576 - Part 2: Implement Intl.Locale firstDayOfWeek option and accessor. r=dminor!
Pushed by andre.bargull@gmail.com: https://github.com/mozilla-firefox/firefox/commit/6db258cfd19d https://hg.mozilla.org/integration/autoland/rev/85b08df62ff8 Part 1: Add preference for Intl.Locale Info proposal. r=dminor https://github.com/mozilla-firefox/firefox/commit/fc2139fa316a https://hg.mozilla.org/integration/autoland/rev/fdf02f5db012 Part 2: Implement Intl.Locale firstDayOfWeek option and accessor. r=dminor https://github.com/mozilla-firefox/firefox/commit/aea14545b5f0 https://hg.mozilla.org/integration/autoland/rev/5d353dc1ac86 Part 3: Enable Intl.Locale firstDayOfWeek test262 tests. r=dminor https://github.com/mozilla-firefox/firefox/commit/779c25cdab97 https://hg.mozilla.org/integration/autoland/rev/e8959c146554 Part 4: Update Intl.Locale compartment tests. r=dminor https://github.com/mozilla-firefox/firefox/commit/cbd0327a0c31 https://hg.mozilla.org/integration/autoland/rev/e7d590a88e37 Part 5: Add locale_glue to get the text direction. r=dminor https://github.com/mozilla-firefox/firefox/commit/c53675b03d77 https://hg.mozilla.org/integration/autoland/rev/2ef86ecbbb56 Part 6: Implement Intl.Locale.prototype.getTextInfo. r=dminor https://github.com/mozilla-firefox/firefox/commit/b15dd993ae82 https://hg.mozilla.org/integration/autoland/rev/b8be7ba86ce0 Part 7: Implement Intl.Locale.prototype.getNumberingSystems. r=dminor https://github.com/mozilla-firefox/firefox/commit/e1050b2f8a43 https://hg.mozilla.org/integration/autoland/rev/ce7ff3840e95 Part 8: Implement Intl.Locale.prototype.getCollations. r=dminor https://github.com/mozilla-firefox/firefox/commit/02c3e9febce0 https://hg.mozilla.org/integration/autoland/rev/5a56251747e5 Part 9: Add mozilla::intl::Region. r=dminor https://github.com/mozilla-firefox/firefox/commit/d24105e902af https://hg.mozilla.org/integration/autoland/rev/4bb0a76f8542 Part 10: Implement RegionPreference and CanonicalUnicodeSubdivision operations. r=dminor https://github.com/mozilla-firefox/firefox/commit/5bba2aaf19ca https://hg.mozilla.org/integration/autoland/rev/56df56a3efce Part 11: Add region-based methods for Calendar. r=dminor https://github.com/mozilla-firefox/firefox/commit/1d0595eeb15b https://hg.mozilla.org/integration/autoland/rev/1cbb0776696c Part 12: Implement Intl.Locale.prototype.getCalendars. r=dminor https://github.com/mozilla-firefox/firefox/commit/9d06209de316 https://hg.mozilla.org/integration/autoland/rev/83b22b8742ca Part 13: Implement Intl.Locale.prototype.getHourCycles. r=dminor https://github.com/mozilla-firefox/firefox/commit/4b493e948516 https://hg.mozilla.org/integration/autoland/rev/a855823d2a11 Part 14: Implement Intl.Locale.prototype.getWeekInfo. r=dminor https://github.com/mozilla-firefox/firefox/commit/2a21c54594ef https://hg.mozilla.org/integration/autoland/rev/136adbf190fb Part 15: Implement Intl.Locale.prototype.getTimeZones. r=dminor
Pushed by nfay@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/9507d3d9734a https://hg.mozilla.org/integration/autoland/rev/833f66013c13 Revert "Bug 1693576 - Part 15: Implement Intl.Locale.prototype.getTimeZones. r=dminor" for causing bustage @ Locale.cpp

Backed out for causing bustage @ Locale.cpp

Backout link

Push with failures

Failure log

Flags: needinfo?(andrebargull)
Flags: needinfo?(andrebargull)
Pushed by andre.bargull@gmail.com: https://github.com/mozilla-firefox/firefox/commit/e198e88eaae9 https://hg.mozilla.org/integration/autoland/rev/84a6690e5d25 Part 1: Add preference for Intl.Locale Info proposal. r=dminor https://github.com/mozilla-firefox/firefox/commit/af6e8ed26369 https://hg.mozilla.org/integration/autoland/rev/313d4c4c5a70 Part 2: Implement Intl.Locale firstDayOfWeek option and accessor. r=dminor https://github.com/mozilla-firefox/firefox/commit/266c5f7fbe45 https://hg.mozilla.org/integration/autoland/rev/3c20b54a8332 Part 3: Enable Intl.Locale firstDayOfWeek test262 tests. r=dminor https://github.com/mozilla-firefox/firefox/commit/1f1ef5868999 https://hg.mozilla.org/integration/autoland/rev/bf47a8739a14 Part 4: Update Intl.Locale compartment tests. r=dminor https://github.com/mozilla-firefox/firefox/commit/7fc1e0487a51 https://hg.mozilla.org/integration/autoland/rev/c33d244e638f Part 5: Add locale_glue to get the text direction. r=dminor https://github.com/mozilla-firefox/firefox/commit/9169b2dba3bf https://hg.mozilla.org/integration/autoland/rev/dd423fda0778 Part 6: Implement Intl.Locale.prototype.getTextInfo. r=dminor https://github.com/mozilla-firefox/firefox/commit/0b48c0961e2a https://hg.mozilla.org/integration/autoland/rev/edfebd30076a Part 7: Implement Intl.Locale.prototype.getNumberingSystems. r=dminor https://github.com/mozilla-firefox/firefox/commit/5f9f59174211 https://hg.mozilla.org/integration/autoland/rev/b881fccf10d5 Part 8: Implement Intl.Locale.prototype.getCollations. r=dminor https://github.com/mozilla-firefox/firefox/commit/3be6127d0f20 https://hg.mozilla.org/integration/autoland/rev/b65263c12398 Part 9: Add mozilla::intl::Region. r=dminor https://github.com/mozilla-firefox/firefox/commit/50ccd60e6681 https://hg.mozilla.org/integration/autoland/rev/0351d8300630 Part 10: Implement RegionPreference and CanonicalUnicodeSubdivision operations. r=dminor https://github.com/mozilla-firefox/firefox/commit/253ba319b022 https://hg.mozilla.org/integration/autoland/rev/39ddc2b7a87e Part 11: Add region-based methods for Calendar. r=dminor https://github.com/mozilla-firefox/firefox/commit/0664350e2e1e https://hg.mozilla.org/integration/autoland/rev/2e7046c6a91a Part 12: Implement Intl.Locale.prototype.getCalendars. r=dminor https://github.com/mozilla-firefox/firefox/commit/8b3cd992bc34 https://hg.mozilla.org/integration/autoland/rev/52c4257c2c82 Part 13: Implement Intl.Locale.prototype.getHourCycles. r=dminor https://github.com/mozilla-firefox/firefox/commit/0f69cf68d13a https://hg.mozilla.org/integration/autoland/rev/d6b9d2985593 Part 14: Implement Intl.Locale.prototype.getWeekInfo. r=dminor https://github.com/mozilla-firefox/firefox/commit/6a52dfd09fa2 https://hg.mozilla.org/integration/autoland/rev/cffe3dbfd93a Part 15: Implement Intl.Locale.prototype.getTimeZones. r=dminor
Keywords: leave-open
Blocks: 2037069

Is this something we should call out in the Fx152 relnotes? Please add a relnote-firefox? nomination if yes.

Flags: needinfo?(andrebargull)

The feature is still behind a flag + Nightly-only. The current plan is to ship it in Firefox 153 (bug 2037069), so I guess relnote-firefox? should be added to that bug?

Flags: needinfo?(andrebargull)

Yeah, we can wait. Sorry, I missed that it was still disabled by default. FYI, we can add a Nightly-only release note too if/when it's enabled there before it's ready to ride the trains.

QA Whiteboard: [qa-triage-done-c153/b152]

FF152 MDN docs work for this can be tracked in https://github.com/mdn/content/issues/44172 (update to experimental features and a compatibility data update).

Bug was resolved, but the web-feature intl-locale-info (definition file) is not yet marked as supported in Firefox.

Feature bugs are usually automatically closed once the corresponding web-features are marked as supported; this typically happens after the feature reaches release.

Status: RESOLVED → REOPENED
Keywords: web-feature
Resolution: FIXED → ---
Status: REOPENED → RESOLVED
Closed: 5 months ago → 2 months ago
Resolution: --- → FIXED
User Story: (updated)
Whiteboard: [DocArea=JS][platform-feature][webcompat:risk-moderate] → [DocArea=JS][platform-feature]
You need to log in before you can comment on or make changes to this bug.