mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-05 22:52:10 +02:00
LibJS: Allow "approximately" results to differ in plural form
This is a normative change in the Intl.NumberFormat V3 spec. See: https://github.com/tc39/proposal-intl-numberformat-v3/commit/08f599b Note that this didn't seem to actually affect our implementation. The Unicode spec states: https://www.unicode.org/reports/tr35/tr35-53/tr35-numbers.html#Plural_Ranges "If there is no value for a <start,end> pair, the default result is end" Therefore, our implementation did not have the behavior noted by the issue this normative change addressed: const pr = new Intl.PluralRules("en-US"); pr.selectRange(1, 1); // Is "other", should be "one" Our implementation already returned "one" here because there is no such <start=one, end=one> value in the CLDR for en-US. Thus, we already returned the end value of "one".
This commit is contained in:
@@ -181,7 +181,7 @@ ThrowCompletionOr<Vector<PatternPartitionWithUnit>> partition_relative_time_patt
|
||||
auto plurality = MUST_OR_THROW_OOM(resolve_plural(vm, relative_time_format.plural_rules(), Value(value)));
|
||||
|
||||
// 22. Let pattern be po.[[<pr>]].
|
||||
auto pattern = patterns.find_if([&](auto& p) { return p.plurality == plurality; });
|
||||
auto pattern = patterns.find_if([&](auto& p) { return p.plurality == plurality.plural_category; });
|
||||
if (pattern == patterns.end())
|
||||
return Vector<PatternPartitionWithUnit> {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user