Skip to content

Conversation

@jedel1043
Copy link
Member

A pending task after migrating to ICU4X 2.0 was to use the newly introduced locale preferences to clean up our Intl implementation. This PR takes care of that by introducing the ServicePreferences trait and removing the Service::resolve method, which makes the code much more modular overall.

cc @sffc, it might be interesting to see if we can upstream parts of the ServicePreferences trait, like as_unicode or intersection.

@jedel1043 jedel1043 added this to the v1.0.0 milestone Jan 23, 2026
@jedel1043 jedel1043 requested a review from a team January 23, 2026 20:32
@jedel1043 jedel1043 added Internal Category for changelog Intl Changes related to the `Intl` implementation labels Jan 23, 2026
@github-actions
Copy link

Test262 conformance changes

Test result main count PR count difference
Total 52,598 52,598 0
Passed 49,421 49,422 +1
Ignored 2,134 2,134 0
Failed 1,043 1,042 -1
Panics 0 0 0
Conformance 93.96% 93.96% +0.00%
Fixed tests (1):
test/intl402/NumberFormat/prototype/resolvedOptions/basic.js (previously Failed)

@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

❌ Patch coverage is 33.33333% with 106 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.50%. Comparing base (6ddc2b4) to head (796ca0b).
⚠️ Report is 633 commits behind head on main.

Files with missing lines Patch % Lines
core/engine/src/builtins/intl/collator/options.rs 0.00% 32 Missing ⚠️
core/engine/src/builtins/intl/number_format/mod.rs 0.00% 24 Missing ⚠️
.../engine/src/builtins/intl/number_format/options.rs 0.00% 21 Missing ⚠️
...gine/src/builtins/intl/date_time_format/options.rs 61.29% 12 Missing ⚠️
core/engine/src/builtins/intl/options.rs 0.00% 9 Missing ⚠️
core/engine/src/builtins/intl/collator/mod.rs 0.00% 5 Missing ⚠️
core/engine/src/builtins/intl/locale/tests.rs 92.59% 2 Missing ⚠️
...e/engine/src/builtins/intl/date_time_format/mod.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4589      +/-   ##
==========================================
+ Coverage   47.24%   56.50%   +9.26%     
==========================================
  Files         476      547      +71     
  Lines       46892    60036   +13144     
==========================================
+ Hits        22154    33926   +11772     
- Misses      24738    26110    +1372     

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

@jedel1043 jedel1043 requested a review from nekevss January 23, 2026 22:02
result
}

fn intersection(&self, other: &Self) -> Self {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preferences have a merge operation already

Copy link
Member Author

@jedel1043 jedel1043 Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This the opposite though; it takes two preference objects and gets the preferences that are the same in both.

We need this because ECMA402 requires correctly setting up the locale with the extensions that were "used" by the locale resolution algorithm. Here I implemented that by first extending the locale prefs with the option prefs, then taking the intersection of the full prefs with the locale prefs to see which ones were not changed.

});
}

fn as_unicode(&self) -> unicode::Unicode {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in some cases we have impl From Preferences for Locale

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also thought that, but after looking at the preferences code, it seems like it was commented out:
https://github.com/unicode-org/icu4x/blob/5fb31d7ae061d304088f1e79897f7435f1846da6/components/locale_core/src/preferences/mod.rs#L519-L533

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably there just wasnt a need for it yet.

fn validate(&mut self, id: &LanguageIdentifier, provider: &IntlProvider) {
self.collation_type = self.collation_type.take().filter(|co| {
let attr = DataMarkerAttributes::from_str_or_panic(co.as_str());
co != &CollationType::Search
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, this is Ecma specific functionality so it should be here in boa

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, extension validation like this seems to be a good candidate for a future "icu4x-ecma402" glue crate

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

Labels

Internal Category for changelog Intl Changes related to the `Intl` implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants