fallback fonts

This commit is contained in:
galister
2026-01-07 03:41:07 +09:00
parent 954e1c3157
commit 578165ee5b
4 changed files with 16 additions and 8 deletions

View File

@@ -58,6 +58,7 @@ impl Translation {
}
pub struct I18n {
lang: String,
json_root_translated: serde_json::Value, // any language
json_root_fallback: serde_json::Value, // english
}
@@ -123,11 +124,16 @@ impl I18n {
.context("Translation file not valid JSON")?;
Ok(Self {
lang,
json_root_translated,
json_root_fallback,
})
}
pub fn get_lang(&self) -> &str {
&self.lang
}
pub fn translate(&mut self, translation_key_full: &str) -> Rc<str> {
let mut sections = translation_key_full.split(';');
let translation_key = sections.next().map_or(translation_key_full, |a| a);