mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibJS: Use Intl.PluralRules within Intl.DurationFormat
This commit is contained in:
parent
232df4196b
commit
1fc87d1529
Notes:
sideshowbarker
2024-07-17 09:36:10 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/1fc87d1529 Pull-request: https://github.com/SerenityOS/serenity/pull/14516 Reviewed-by: https://github.com/linusg ✅
1 changed files with 8 additions and 3 deletions
|
@ -435,13 +435,18 @@ ThrowCompletionOr<Vector<PatternPartition>> partition_duration_format_pattern(Gl
|
|||
// t. Else,
|
||||
else {
|
||||
// i. Let pr be ? Construct(%PluralRules%, « durationFormat.[[Locale]] »).
|
||||
auto* plural_rules = TRY(construct(global_object, *global_object.intl_plural_rules_constructor(), js_string(vm, duration_format.locale())));
|
||||
|
||||
// ii. Let prv be ! ResolvePlural(pr, value).
|
||||
// FIXME: Use ResolvePlural when Intl.PluralRules is implemented.
|
||||
auto plurality = resolve_plural(global_object, static_cast<PluralRules&>(*plural_rules), value);
|
||||
|
||||
auto formats = Unicode::get_unit_formats(data_locale, duration_instances_component.unit_singular, static_cast<Unicode::Style>(style));
|
||||
auto pattern = Unicode::select_pattern_with_plurality(formats, value.as_double()).release_value();
|
||||
auto pattern = formats.find_if([&](auto& p) { return p.plurality == plurality; });
|
||||
if (pattern == formats.end())
|
||||
continue;
|
||||
|
||||
// iii. Let template be the current value of the prv slot of the unit slot of the style slot of dataLocaleData.[[formats]].
|
||||
auto template_ = convert_number_format_pattern_to_duration_format_template(pattern);
|
||||
auto template_ = convert_number_format_pattern_to_duration_format_template(*pattern);
|
||||
|
||||
// FIXME: MakePartsList takes a list, not a string, so likely missing spec step: Let fv be ! PartitionNumberPattern(nf, value).
|
||||
auto formatted_value = partition_number_pattern(global_object, *number_format, value);
|
||||
|
|
Loading…
Reference in a new issue