// Internationalisation surface for the installer.
//
// `rust_i18n::i18n!()` is invoked from `main.rs` so the proc macro picks
// up `CARGO_MANIFEST_DIR/locales`. ltk runs its own `i18n!()` invocation
// in its `lib.rs`; per the rust-i18n contract both registries merge into
// a single global table at runtime, so `t!()` resolves any key from
// either side.

/// Catalogue of supported locales for the installer. The `code` is the
/// rust-i18n locale id (matches the YAML filename without extension);
/// the `endonym` is the language name written in itself, used by the
/// language picker (screen 02). Endonyms are kept in code rather than
/// in YAML because they must render in any active locale, including
/// before the user has picked one.
pub struct Language
{
	pub code:    &'static str,
	pub endonym: &'static str,
}

pub const SUPPORTED: &[ Language ] = &[
	Language { code: "en", endonym: "English"  },
	Language { code: "es", endonym: "Español"  },
	Language { code: "zh", endonym: "中文"      },
	Language { code: "hi", endonym: "हिन्दी"     },
	Language { code: "fr", endonym: "Français" },
	Language { code: "de", endonym: "Deutsch"  },
	Language { code: "pt", endonym: "Português" },
	Language { code: "ja", endonym: "日本語"    },
	Language { code: "ru", endonym: "Русский"  },
	Language { code: "ko", endonym: "한국어"    },
];

/// Default locale — also the rust-i18n fallback declared in `main.rs`.
pub const DEFAULT: &str = "en";

/// Set the active locale globally. Subsequent `t!()` calls resolve
/// against `code`; unknown keys fall back to `DEFAULT`.
pub fn set_locale( code: &str )
{
	rust_i18n::set_locale( code );
}

/// The rust-i18n macro for in-place translation. Re-exported so screen
/// modules can write `use crate::i18n::tr;` and call `tr!( "welcome.title" )`.
pub use rust_i18n::t as tr;
