mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 20:28:11 +00:00
LibUnicode: Replace NumberFormat::Plurality with Unicode::PluralCategory
To prepare for using plural rules within number & duration format, this removes the NumberFormat::Plurality enumeration. This also adds PluralCategory::ExactlyZero & PluralCategory::ExactlyOne. These are used in locales like French, where PluralCategory::One really means any value from 0.00 to 1.99. PluralCategory::ExactlyOne means only the value 1, as the name implies. These exact rules are not known by the general plural rules, they are explicitly for number / currency format.
This commit is contained in:
parent
cc5c707649
commit
232df4196b
3 changed files with 26 additions and 40 deletions
|
@ -25,6 +25,10 @@ enum class PluralCategory : u8 {
|
|||
Two,
|
||||
Few,
|
||||
Many,
|
||||
|
||||
// https://unicode.org/reports/tr35/tr35-numbers.html#Explicit_0_1_rules
|
||||
ExactlyZero,
|
||||
ExactlyOne,
|
||||
};
|
||||
|
||||
// https://unicode.org/reports/tr35/tr35-numbers.html#Plural_Operand_Meanings
|
||||
|
@ -81,6 +85,10 @@ constexpr PluralCategory plural_category_from_string(StringView category)
|
|||
return PluralCategory::Few;
|
||||
if (category == "many"sv)
|
||||
return PluralCategory::Many;
|
||||
if (category == "0"sv)
|
||||
return PluralCategory::ExactlyZero;
|
||||
if (category == "1"sv)
|
||||
return PluralCategory::ExactlyOne;
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
|
@ -100,6 +108,10 @@ constexpr StringView plural_category_to_string(PluralCategory category)
|
|||
return "few"sv;
|
||||
case PluralCategory::Many:
|
||||
return "many"sv;
|
||||
case PluralCategory::ExactlyZero:
|
||||
return "0"sv;
|
||||
case PluralCategory::ExactlyOne:
|
||||
return "1"sv;
|
||||
}
|
||||
|
||||
VERIFY_NOT_REACHED();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue