Add selector tests for the `fr` locale

finchie
Jul 31, 2024, 9:18 AM
AAERM7PBDVDFDEEXZ7UJ5WWQF7SPEJQQYXRBZ63ETB5YAVIECHMAC

Dependencies

  • [2] 6ABVDTXZ Improve `fluent_embed_derive` test suite
  • [3] XEEXWJLG Add simple end-to-end test for selectors
  • [4] HHJDRLLN Create `fluent_embed_runtime` crate
  • [5] KZLFC7OW Rename `fluent_embed_runtime` to `fluent_embed`
  • [6] OWXLFLRM Merge `cli_macros` shim into `fluent_embed`
  • [*] VNSHGQYN Support using glob paths in `localize` macro

Change contents

  • replacement in fluent_embed_derive/tests/selectors.rs at line 3
    [3.243][3.17:45](),[3.45][3.31:59]()
    use fluent_embed::localize;
    use fluent_embed::Localize;
    [3.243]
    [2.0]
    use fluent_embed::{localize, Localize};
    use icu_locid::LanguageIdentifier;
  • replacement in fluent_embed_derive/tests/selectors.rs at line 6
    [2.34][2.34:54]()
    use rstest::rstest;
    [2.34]
    [3.340]
    use rstest::{fixture, rstest};
  • edit in fluent_embed_derive/tests/selectors.rs at line 13
    [3.615]
    [2.55]
    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 singular
    1 => format!("You have {unread_emails} unread email."),
    // Everything else is plural
    0 | 2.. => format!("You have {unread_emails} unread emails."),
    },
    "fr" => match unread_emails {
    // Both 0 & 1 are singular
    0 | 1 => format!("Vous avez {unread_emails} e-mail non lu."),
    // Everything else is plural
    2.. => format!("Vous avez {unread_emails} e-mails non lus."),
    },
    _ => unreachable!(),
    },
    }
    }
    }
    /// End-to-end test of locale-specific selectors implementation by checking final output
  • replacement in fluent_embed_derive/tests/selectors.rs at line 37
    [2.65][2.65:315]()
    #[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) {
    [2.65]
    [2.315]
    fn message_for_locale(
    #[values(0, 1, 2, u64::MAX)] unread_emails: u64,
    #[values("en-US", "fr")] locale: &str,
    ) {
  • replacement in fluent_embed_derive/tests/selectors.rs at line 42
    [2.366][2.366:410]()
    assert_eq!(&data.localize(), expected);
    [2.366]
    [3.1111]
    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 expect
    let expected_message = data.expected_message(locale);
    assert_eq!(data.message_for_locale(&language_id), expected_message);
  • file addition: fr (d--r------)
    [8.971]
  • file addition: selectors.ftl (----------)
    [0.1538]
    emails =
    { $unreadEmails ->
    [one] Vous avez { $unreadEmails } e-mail non lu.
    *[other] Vous avez { $unreadEmails } e-mails non lus.
    }