//! `AuthFtlContributor` — registers framework-level auth translations.
//!
//! Contributes `features/auth.ftl` and `features/auth-signout.ftl` for each
//! language embedded at compile time from `rustelo/resources/i18n/`.
//!
//! ## Registration
//!
//! ```rust,no_run
//! use rustelo_auth::contributor::AuthFtlContributor;
//! use rustelo_auth::register_contributor;
//!
//! register_contributor(&AuthFtlContributor).expect("auth FTL registration");
//! ```

use std::collections::HashMap;

use rustelo_core_lib::registration::ResourceContributor;

/// Contributes embedded framework auth FTL strings to the global registry.
///
/// Keys: `"en_auth"`, `"en_auth_signout"`, `"es_auth"`, `"es_auth_signout"`, …
pub struct AuthFtlContributor;

impl ResourceContributor for AuthFtlContributor {
    fn contribute_ftl(&self) -> HashMap<String, String> {
        crate::get_auth_ftl()
            .into_iter()
            .map(|(k, v)| (k.to_owned(), v.to_owned()))
            .collect()
    }

    fn name(&self) -> &str {
        "rustelo_auth"
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn contributor_has_name() {
        assert_eq!(AuthFtlContributor.name(), "rustelo_auth");
    }

    #[test]
    fn contribute_ftl_returns_map() {
        let map = AuthFtlContributor.contribute_ftl();
        let _ = map.len();
    }
}
