Framework for embedding localizations into Rust types
//! End-to-end test for recursive localization support in the `l10n_embed_derive` macro

mod common;

use common::compare_message;
use icu_locale::locale;
use l10n_embed_derive::localize;

#[localize("tests/locale/**/basic.ftl")]
pub struct Title {
    name: String,
}

#[localize("tests/locale/**/basic.ftl")]
pub struct Praise {
    name: Title,
}

#[localize("tests/locale/**/basic.ftl")]
pub struct Greeting {
    name: Praise,
}

#[test]
fn once() {
    let name = Title {
        name: String::from("Ferris"),
    };
    compare_message(
        Praise { name },
        "the Excellent Ferris the crab",
        locale!("en-US"),
    )
}

#[test]
fn twice() {
    let name = Praise {
        name: Title {
            name: String::from("Ferris"),
        },
    };
    compare_message(
        Greeting { name },
        "Hello, the Excellent Ferris the crab!",
        locale!("en-US"),
    )
}