From f672b4c151daf48ac35cd2409b4065f3ec4afae1 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Fri, 8 Jul 2022 12:08:31 -0400 Subject: LibUnicode: Remove now-unused Unicode::select_pattern_with_plurality --- Userland/Libraries/LibUnicode/NumberFormat.h | 29 ---------------------------- 1 file changed, 29 deletions(-) (limited to 'Userland') diff --git a/Userland/Libraries/LibUnicode/NumberFormat.h b/Userland/Libraries/LibUnicode/NumberFormat.h index c25226ea7d..dda885fd18 100644 --- a/Userland/Libraries/LibUnicode/NumberFormat.h +++ b/Userland/Libraries/LibUnicode/NumberFormat.h @@ -72,33 +72,4 @@ Vector get_unit_formats(StringView locale, StringView unit, Style Optional augment_currency_format_pattern(StringView currency_display, StringView base_pattern); -template -Optional select_pattern_with_plurality(Vector 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 { - 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); -} - } -- cgit v1.2.3