Name Description Size
lib.rs A crate for generating plural rule operands from numberical input. This crate generates plural operands according to the specifications outlined at [Unicode's website](https://unicode.org/reports/tr35/tr35-numbers.html#Operands). Input is supported for int, float, and &str. # Examples Plural rules example for Polish ``` use intl_pluralrules::{PluralRules, PluralRuleType, PluralCategory}; use unic_langid::LanguageIdentifier; let langid: LanguageIdentifier = "pl".parse().expect("Parsing failed."); assert!(PluralRules::get_locales(PluralRuleType::CARDINAL).contains(&langid)); let pr = PluralRules::create(langid.clone(), PluralRuleType::CARDINAL).unwrap(); assert_eq!(pr.select(1), Ok(PluralCategory::ONE)); assert_eq!(pr.select("3"), Ok(PluralCategory::FEW)); assert_eq!(pr.select(12), Ok(PluralCategory::MANY)); assert_eq!(pr.select("5.0"), Ok(PluralCategory::OTHER)); assert_eq!(pr.get_locale(), &langid); ``` 7813
operands.rs Plural operands in compliance with [CLDR Plural Rules](https://unicode.org/reports/tr35/tr35-numbers.html#Language_Plural_Rules). See [full operands description](https://unicode.org/reports/tr35/tr35-numbers.html#Operands). # Examples From int ``` use std::convert::TryFrom; use intl_pluralrules::operands::*; assert_eq!(Ok(PluralOperands { n: 2_f64, i: 2, v: 0, w: 0, f: 0, t: 0, }), PluralOperands::try_from(2)) ``` From float ``` use std::convert::TryFrom; use intl_pluralrules::operands::*; assert_eq!(Ok(PluralOperands { n: 1234.567_f64, i: 1234, v: 3, w: 3, f: 567, t: 567, }), PluralOperands::try_from("-1234.567")) ``` From &str ``` use std::convert::TryFrom; use intl_pluralrules::operands::*; assert_eq!(Ok(PluralOperands { n: 123.45_f64, i: 123, v: 2, w: 2, f: 45, t: 45, }), PluralOperands::try_from(123.45)) ``` 5350
rules.rs 89022