mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibUnicode: Remove now-unused Unicode::select_pattern_with_plurality
This commit is contained in:
parent
5b68c1a06c
commit
f672b4c151
Notes:
sideshowbarker
2024-07-17 09:35:59 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/f672b4c151 Pull-request: https://github.com/SerenityOS/serenity/pull/14516 Reviewed-by: https://github.com/linusg ✅
1 changed files with 0 additions and 29 deletions
|
@ -72,33 +72,4 @@ Vector<NumberFormat> get_unit_formats(StringView locale, StringView unit, Style
|
|||
|
||||
Optional<String> augment_currency_format_pattern(StringView currency_display, StringView base_pattern);
|
||||
|
||||
template<typename FormatType>
|
||||
Optional<FormatType> select_pattern_with_plurality(Vector<FormatType> const& formats, double number)
|
||||
{
|
||||
// FIXME: This is a rather naive and locale-unaware implementation Unicode's TR-35 pluralization
|
||||
// rules: https://www.unicode.org/reports/tr35/tr35-numbers.html#Language_Plural_Rules
|
||||
// Once those rules are implemented for LibJS, we better use them instead.
|
||||
auto find_plurality = [&](auto plurality) -> Optional<FormatType> {
|
||||
if (auto it = formats.find_if([&](auto& patterns) { return patterns.plurality == plurality; }); it != formats.end())
|
||||
return *it;
|
||||
return {};
|
||||
};
|
||||
|
||||
if (number == 0) {
|
||||
if (auto patterns = find_plurality(PluralCategory::Zero); patterns.has_value())
|
||||
return patterns;
|
||||
} else if (number == 1) {
|
||||
if (auto patterns = find_plurality(PluralCategory::One); patterns.has_value())
|
||||
return patterns;
|
||||
} else if (number == 2) {
|
||||
if (auto patterns = find_plurality(PluralCategory::Two); patterns.has_value())
|
||||
return patterns;
|
||||
} else if (number > 2) {
|
||||
if (auto patterns = find_plurality(PluralCategory::Many); patterns.has_value())
|
||||
return patterns;
|
||||
}
|
||||
|
||||
return find_plurality(PluralCategory::Other);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue