intl_local/lib/src/plural_rules library
Provides locale-specific plural rules. Based on pluralrules.js from Closure.
Each function does the calculation for one or more locales. These are done in terms of various values used by the CLDR syntax and defined by UTS #35 http://unicode.org/reports/tr35/tr35-numbers.html#Plural_rules_syntax
- n - absolute value of the source number (integer and decimals).
- i - integer digits of n.
- v - number of visible fraction digits in n, with trailing zeros.
- w - number of visible fraction digits in n, without trailing zeros.
- f - visible fractional digits in n, with trailing zeros.
- t - visible fractional digits in n, without trailing zeros.
Enums
- PluralCase
- The possible cases used in a plural rule.
Properties
- FEW → PluralCase
-
no setter
- MANY → PluralCase
-
no setter
- ONE → PluralCase
-
no setter
- OTHER → PluralCase
-
no setter
-
pluralRules
→ Map<
String, PluralCase Function()> -
Selected Plural rules by locale.
final
- TWO → PluralCase
-
no setter
- ZERO → PluralCase
-
no setter
Functions
-
localeHasPluralRules(
String locale) → bool -
Do we have plural rules specific to
locale
-
startRuleEvaluation(
num howMany, [int? precision = 0]) → void - This must be called before evaluating a new rule, because we're using library-global state to both keep the rules terse and minimize space.
Typedefs
- PluralRule = PluralCase Function()