[][src]Crate intl_pluralrules

A crate for generating plural rule operands from numberical input.

This crate generates plural operands according to the specifications outlined at Unicode's website.

Input is supported for int, float, and &str.

Examples

Plural rules example for Polish

use intl_pluralrules::{IntlPluralRules, PluralRuleType, PluralCategory};

let locale_code = "pl";
  
assert!(IntlPluralRules::get_locales(PluralRuleType::CARDINAL).contains(&locale_code));

let pr = IntlPluralRules::create(locale_code, 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(), locale_code);

Modules

operands

A public AST module for plural rule representations. Plural operands in compliance with CLDR Plural Rules.

Structs

IntlPluralRules

The main structure for selecting plural rules.

Enums

PluralCategory

A public enum for handling the plural category. Each plural category will vary, depending on the language that is being used and whether that language has that plural category.

PluralRuleType

A public enum for handling plural type.

Statics

CLDR_VERSION