diff options
author | metamuffin <metamuffin@disroot.org> | 2025-04-28 00:48:52 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-04-28 00:48:52 +0200 |
commit | 80d28b764c95891551e28c395783f5ff9d065743 (patch) | |
tree | f25898b1c939a939c63236ca4e8e843e81069947 /base | |
parent | 335ba978dbaf203f3603a815147fd75dbf205723 (diff) | |
download | jellything-80d28b764c95891551e28c395783f5ff9d065743.tar jellything-80d28b764c95891551e28c395783f5ff9d065743.tar.bz2 jellything-80d28b764c95891551e28c395783f5ff9d065743.tar.zst |
start with splitting server
Diffstat (limited to 'base')
-rw-r--r-- | base/src/lib.rs | 1 | ||||
-rw-r--r-- | base/src/locale.rs | 34 |
2 files changed, 0 insertions, 35 deletions
diff --git a/base/src/lib.rs b/base/src/lib.rs index c897754..010e908 100644 --- a/base/src/lib.rs +++ b/base/src/lib.rs @@ -6,7 +6,6 @@ pub mod assetfed; pub mod database; pub mod federation; -pub mod locale; pub mod permission; pub use jellycommon as common; diff --git a/base/src/locale.rs b/base/src/locale.rs deleted file mode 100644 index e7f1592..0000000 --- a/base/src/locale.rs +++ /dev/null @@ -1,34 +0,0 @@ -use std::{borrow::Cow, collections::HashMap, sync::LazyLock}; - -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -pub enum Language { - English, - German, -} - -static LANG_TABLES: LazyLock<HashMap<Language, HashMap<&'static str, &'static str>>> = - LazyLock::new(|| { - let mut k = HashMap::new(); - for (lang, source) in [ - (Language::English, include_str!("../../locale/en.ini")), - (Language::German, include_str!("../../locale/de.ini")), - ] { - let tr_map = source - .lines() - .filter_map(|line| { - let (key, value) = line.split_once("=")?; - Some((key.trim(), value.trim())) - }) - .collect::<HashMap<&'static str, &'static str>>(); - k.insert(lang, tr_map); - } - k - }); - -pub fn tr(lang: Language, key: &str) -> Cow<'static, str> { - let tr_map = LANG_TABLES.get(&lang).unwrap(); - match tr_map.get(key) { - Some(value) => Cow::Borrowed(value), - None => Cow::Owned(format!("TR[{key}]")), - } -} |