1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-08 05:27:14 +09:00

LibJS: Ensure relevant extension keys are included in ICU locale data

This is a normative change in the ECMA-402 spec. See:
7508197

In our implementation, we don't have the affected AOs directly, as we
delegate to ICU. So instead, we must ensure we provide ICU a locale with
the relevant extension keys present.
This commit is contained in:
Timothy Flynn 2025-03-17 16:24:09 -04:00 committed by Tim Flynn
parent 37b8ba96f1
commit 00d00b84d3
Notes: github-actions[bot] 2025-03-18 15:48:22 +00:00
17 changed files with 82 additions and 67 deletions

View file

@ -38,7 +38,7 @@ DigitalFormat digital_format(StringView locale)
rounding_options.min_significant_digits = 1;
rounding_options.max_significant_digits = 2;
auto number_formatter = NumberFormat::create(locale, "latn"sv, {}, rounding_options);
auto number_formatter = NumberFormat::create(locale, {}, rounding_options);
auto icu_locale = adopt_own(*locale_data->locale().clone());
icu_locale->setUnicodeKeywordValue("nu", "latn", status);

View file

@ -866,12 +866,9 @@ private:
NonnullOwnPtr<NumberFormat> NumberFormat::create(
StringView locale,
StringView numbering_system,
DisplayOptions const& display_options,
RoundingOptions const& rounding_options)
{
UErrorCode status = U_ZERO_ERROR;
auto locale_data = LocaleData::for_locale(locale);
VERIFY(locale_data.has_value());
@ -879,11 +876,6 @@ NonnullOwnPtr<NumberFormat> NumberFormat::create(
apply_display_options(formatter, display_options);
apply_rounding_options(formatter, rounding_options);
if (!numbering_system.is_empty()) {
if (auto* symbols = icu::NumberingSystem::createInstanceByName(ByteString(numbering_system).characters(), status); symbols && icu_success(status))
formatter = formatter.adoptSymbols(symbols);
}
bool is_unit = display_options.style == NumberFormatStyle::Unit;
return adopt_own(*new NumberFormatImpl(locale_data->locale(), move(formatter), is_unit));
}

View file

@ -142,7 +142,6 @@ class NumberFormat {
public:
static NonnullOwnPtr<NumberFormat> create(
StringView locale,
StringView numbering_system,
DisplayOptions const&,
RoundingOptions const&);