Skip to main content

cloudiful_bevy_localization/
definition.rs

1use crate::{Locale, TextKey};
2
3#[derive(Debug, Clone, Copy)]
4pub struct LocaleSource {
5    pub locale: &'static str,
6    pub namespace: &'static str,
7    pub contents: &'static str,
8}
9
10#[derive(Debug)]
11pub struct LocalizationDefinition {
12    pub fallback_locale: &'static str,
13    pub locales: &'static [&'static str],
14    pub sources: &'static [LocaleSource],
15    pub keys: &'static [TextKey],
16}
17
18impl LocalizationDefinition {
19    pub fn fallback_locale(&self) -> Locale {
20        Locale::new(self.fallback_locale)
21    }
22
23    pub fn locales(&self) -> Vec<Locale> {
24        self.locales.iter().copied().map(Locale::new).collect()
25    }
26}