mod backend;
mod builder;
mod core;
mod error;
mod flat_backend;
mod interpolate;
mod locale;
mod macros;
mod plural;
#[cfg(feature = "json-backend")]
mod json_backend;
#[cfg(feature = "yaml-backend")]
mod yaml_backend;
pub use backend::{ChainedBackend, TomlBackend};
pub use builder::I18nBuilder;
pub use core::{Backend, I18n, Reloadable};
pub use error::I18nError;
pub use flat_backend::FlatBackend;
pub use interpolate::interpolate;
pub use locale::{Locale, negotiate_locale};
pub use plural::{PluralCategory, plural_category};
#[cfg(feature = "json-backend")]
pub use json_backend::JsonBackend;
#[cfg(feature = "yaml-backend")]
pub use yaml_backend::YamlBackend;
#[cfg(feature = "init")]
pub use anycms_i18n_macro::i18n;
#[cfg(feature = "init")]
pub use anycms_i18n_macro::embed_locales;
#[cfg(feature = "hot-reload")]
mod hot_reload;
#[cfg(feature = "hot-reload")]
pub use hot_reload::HotReloader;
use std::sync::OnceLock;
static GLOBAL_I18N: OnceLock<I18n> = OnceLock::new();
pub fn set_global(i18n: I18n) -> Result<(), I18n> {
GLOBAL_I18N.set(i18n)
}
pub fn global() -> Option<&'static I18n> {
GLOBAL_I18N.get()
}
#[cfg(feature = "hot-reload")]
static GLOBAL_RELOADER: OnceLock<HotReloader> = OnceLock::new();
#[cfg(feature = "hot-reload")]
pub fn set_global_reloader(reloader: HotReloader) -> Result<(), HotReloader> {
GLOBAL_RELOADER.set(reloader)
}
#[cfg(feature = "task-local")]
tokio::task_local! {
pub static CURRENT_LOCALE: String;
}
#[cfg(feature = "task-local")]
pub fn task_locale() -> Option<String> {
CURRENT_LOCALE.try_with(|l| l.clone()).ok()
}
#[cfg(not(feature = "task-local"))]
pub fn task_locale() -> Option<String> {
None
}