This should be a good test as fr seems to have different plural rules to en-US.
AAERM7PBDVDFDEEXZ7UJ5WWQF7SPEJQQYXRBZ63ETB5YAVIECHMAC impl Messages {fn expected_message(&self, locale: &str) -> String {match self {Self::Emails { unread_emails } => match locale {"en-US" => match unread_emails {// Only 1 is singular1 => format!("You have {unread_emails} unread email."),// Everything else is plural0 | 2.. => format!("You have {unread_emails} unread emails."),},"fr" => match unread_emails {// Both 0 & 1 are singular0 | 1 => format!("Vous avez {unread_emails} e-mail non lu."),// Everything else is plural2.. => format!("Vous avez {unread_emails} e-mails non lus."),},_ => unreachable!(),},}}}/// End-to-end test of locale-specific selectors implementation by checking final output
#[case(0, "You have 0 unread emails.")]#[case(1, "You have 1 unread email.")]#[case(2, "You have 2 unread emails.")]#[case(u64::MAX, "You have 18446744073709551615 unread emails.")]fn english(#[case] unread_emails: u64, #[case] expected: &str) {
fn message_for_locale(#[values(0, 1, 2, u64::MAX)] unread_emails: u64,#[values("en-US", "fr")] locale: &str,) {
assert_eq!(&data.localize(), expected);
let expected_message = data.expected_message(locale);let language_id = LanguageIdentifier::try_from_bytes(locale.as_bytes()).unwrap();// Make sure the generated string is what we expectlet expected_message = data.expected_message(locale);assert_eq!(data.message_for_locale(&language_id), expected_message);
emails ={ $unreadEmails ->[one] Vous avez { $unreadEmails } e-mail non lu.*[other] Vous avez { $unreadEmails } e-mails non lus.}