LibJS+LibLocale: Replace plural rules selection with ICU

This uses ICU for all of the Intl.PluralRules prototypes, which lets us
remove all data from our plural rules generator.

Plural rules depend directly on internal data from the number formatter,
so rather than creating a separate Locale::PluralRules class (which will
make accessing that data awkward), this adds plural rules APIs to the
existing Locale::NumberFormat.
This commit is contained in:
Timothy Flynn 2024-06-14 14:15:28 -04:00 committed by Andreas Kling
commit 5e2ee4447e
Notes: sideshowbarker 2024-07-16 23:38:54 +09:00
14 changed files with 216 additions and 1026 deletions

View file

@ -6,7 +6,6 @@
#pragma once
#include <AK/String.h>
#include <AK/StringView.h>
#include <LibJS/Runtime/Completion.h>
#include <LibJS/Runtime/Intl/NumberFormat.h>
@ -32,15 +31,7 @@ private:
::Locale::PluralForm m_type { ::Locale::PluralForm::Cardinal }; // [[Type]]
};
struct ResolvedPlurality {
::Locale::PluralCategory plural_category; // [[PluralCategory]]
String formatted_string; // [[FormattedString]]
};
::Locale::PluralOperands get_operands(StringView string);
::Locale::PluralCategory plural_rule_select(StringView locale, ::Locale::PluralForm type, Value number, ::Locale::PluralOperands operands);
ResolvedPlurality resolve_plural(PluralRules const&, Value number);
::Locale::PluralCategory plural_rule_select_range(StringView locale, ::Locale::PluralForm, ::Locale::PluralCategory start, ::Locale::PluralCategory end);
::Locale::PluralCategory resolve_plural(PluralRules const&, Value number);
ThrowCompletionOr<::Locale::PluralCategory> resolve_plural_range(VM&, PluralRules const&, Value start, Value end);
}