added support for language files

This commit is contained in:
2025-04-06 15:43:35 +02:00
parent eb0991df53
commit 0c87e5f56a
28 changed files with 1087 additions and 973 deletions
+36
View File
@@ -34,4 +34,40 @@ macro_rules! errln {
);
std::process::exit(1);
};
}
#[macro_export]
macro_rules! lang {
($key:expr) => {
{
use crate::{LANG, errln};
let value = unsafe {
LANG
.as_ref()
.expect("LANG must be initialized before use")
.get($key)
};
if value.is_none() { errln!("Key not found in LANG JSON: \"{}\"", $key); }
value.unwrap().as_str().expect("LANG JSON value is not a string!").to_string()
}
};
($key:expr, $($arg:expr),*) => {{
use crate::{LANG, errln};
use formatx::formatx;
let value = unsafe {
LANG
.as_ref()
.expect("LANG must be initialized before use")
.get($key)
};
if value.is_none() { errln!("Key not found in LANG JSON: \"{}\"", $key); }
let format_str = value.unwrap().as_str().expect("LANG JSON value is not a string!");
formatx!(format_str, $($arg),*).unwrap()
}};
}