Skip to main content

es_fluent_manager_core/
asset_localization.rs

1//! This module provides types for managing asset-based translations.
2
3use unic_langid::LanguageIdentifier;
4
5#[derive(Debug)]
6pub struct AssetModuleData {
7    /// The name of the module.
8    pub name: &'static str,
9    /// The domain of the module.
10    pub domain: &'static str,
11    /// The supported languages of the module.
12    pub supported_languages: &'static [LanguageIdentifier],
13    /// The namespaces used by this module's types (e.g., "ui", "errors").
14    /// If empty, only the main domain file (e.g., `bevy-example.ftl`) is loaded.
15    pub namespaces: &'static [&'static str],
16}
17
18pub trait I18nAssetModule: Send + Sync {
19    /// Returns the data for the module.
20    fn data(&self) -> &'static AssetModuleData;
21}
22
23pub struct AssetI18nModule {
24    data: &'static AssetModuleData,
25}
26
27impl AssetI18nModule {
28    /// Creates a new `AssetI18nModule`.
29    pub const fn new(data: &'static AssetModuleData) -> Self {
30        Self { data }
31    }
32}
33
34impl I18nAssetModule for AssetI18nModule {
35    fn data(&self) -> &'static AssetModuleData {
36        self.data
37    }
38}
39
40inventory::collect!(&'static dyn I18nAssetModule);