Skip to content

feat(Intl): add initial Intl.DisplayNames implementation#5249

Open
Lokesh0224 wants to merge 4 commits intoboa-dev:mainfrom
Lokesh0224:displayNames
Open

feat(Intl): add initial Intl.DisplayNames implementation#5249
Lokesh0224 wants to merge 4 commits intoboa-dev:mainfrom
Lokesh0224:displayNames

Conversation

@Lokesh0224
Copy link
Contributor

Summary

This PR adds an initial implementation of Intl.DisplayNames, as part of the work tracked in #3710.


What's implemented

  • Constructor

    • Validates NewTarget per ECMA-402 §12.1.1 (step 1)
    • Creates the object using the engine’s equivalent of OrdinaryCreateFromConstructor (step 2)
    • Documents steps 3–23 inline for future implementation
  • supportedLocalesOf

  • Options infrastructure

    • DisplayNamesType enum covering all six types:
      language, region, script, currency, calendar, dateTimeField
    • OptionType implementations:
      • Stylenarrow | short | long
      • Fallbackcode | none
      • LanguageDisplaydialect | standard
    • Note: these rely on icu_experimental and may change as icu4x#3913 evolves
  • Tests

    • Unit tests for all valid DisplayNamesType parsing cases

Not yet implemented

  • of()§12.3.3

    • Code canonicalization (CanonicalCodeForDisplayNames, §12.5.1)
    • Field lookup
    • Fallback handling
  • resolvedOptions()§12.3.2

    • Population of properties from internal slots (Table 18)
  • Internal slot storage

    • Mapping of spec internal slots to struct fields:
      [[Locale]], [[Style]], [[Type]], [[Fallback]],
      [[LanguageDisplay]], [[Fields]]

Notes

  • LocaleDisplayNamesV1 is used as a temporary stand-in for Service::LangMarker to support supportedLocalesOf locale availability checks.
  • Intl.DisplayNames supports multiple categories (language, region, script, currency, calendar, dateTimeField), each backed by different ICU providers. Once formatting is implemented, dispatch will occur at runtime in of() based on the type option.
  • The upstream icu4x#3913 is actively progressing, and the remaining data marker design (attribute-based vs. per-type markers, ZeroTrie-backed multi-attribute loading) is targeted for icu4x 2.3. The Service::LangMarker choice will need revisiting once that design stabilizes.
  • Constructor steps 3–23 are intentionally deferred due to ongoing upstream discussions in icu4x#3913, particularly around pattern loading (nested parentheses), find_longest_matching_subtag behavior, and multi-attribute data loading.
  • Style, Fallback, and LanguageDisplay in options.rs are from icu_experimental and subject to change as the upstream API stabilizes. The LanguageDisplay groundwork already aligns with the "support dialect option" item in icu4x#3913.

@Lokesh0224 Lokesh0224 requested review from a team, jedel1043 and nekevss as code owners March 24, 2026 20:06
@github-actions github-actions bot added the Waiting On Review Waiting on reviews from the maintainers label Mar 24, 2026
@github-actions github-actions bot added this to the v1.0.0 milestone Mar 24, 2026
@github-actions github-actions bot added C-Dependencies Pull requests that update a dependency file C-Builtins PRs and Issues related to builtins/intrinsics C-Intl Changes related to the `Intl` implementation labels Mar 24, 2026
@github-actions
Copy link

github-actions bot commented Mar 24, 2026

Test262 conformance changes

Test result main count PR count difference
Total 52,963 52,963 0
Passed 50,732 50,733 +1
Ignored 1,426 1,426 0
Failed 805 804 -1
Panics 0 0 0
Conformance 95.79% 95.79% +0.00%
Fixed tests (1):
test/intl402/DisplayNames/options-languagedisplay-valid.js (previously Failed)

Tested main commit: 8fcbfcbb8b9e70fe878d28376a6496eaa57a70d7
Tested PR commit: 7a6c2e471e6c625489bdc9afa9df966cf70017f5
Compare commits: 8fcbfcb...7a6c2e4

@codecov
Copy link

codecov bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 32.05128% with 53 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.70%. Comparing base (6ddc2b4) to head (7a6c2e4).
⚠️ Report is 918 commits behind head on main.

Files with missing lines Patch % Lines
core/engine/src/builtins/intl/display_names/mod.rs 22.22% 28 Missing ⚠️
.../engine/src/builtins/intl/display_names/options.rs 24.24% 25 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5249       +/-   ##
===========================================
+ Coverage   47.24%   59.70%   +12.46%     
===========================================
  Files         476      591      +115     
  Lines       46892    63486    +16594     
===========================================
+ Hits        22154    37905    +15751     
- Misses      24738    25581      +843     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Builtins PRs and Issues related to builtins/intrinsics C-Dependencies Pull requests that update a dependency file C-Intl Changes related to the `Intl` implementation Waiting On Review Waiting on reviews from the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant