2023-08-18 12:22:23 +02:00
|
|
|
use std::collections::HashMap;
|
|
|
|
|
use lazy_static::lazy_static;
|
|
|
|
|
use leptos::*;
|
2023-09-18 13:10:59 +02:00
|
|
|
use crate::locales::Locales;
|
2023-08-18 12:22:23 +02:00
|
|
|
|
|
|
|
|
lazy_static! {
|
|
|
|
|
static ref LANGUAGES: HashMap<&'static str, HashMap<&'static str, &'static str>> = {
|
|
|
|
|
let m = HashMap::from([
|
|
|
|
|
("cs", HashMap::from( [
|
|
|
|
|
("Dashboard", "Přehled"),
|
|
|
|
|
("Settings", "Nastavení"),
|
2023-08-24 21:58:03 +02:00
|
|
|
("Search...", "Najít..."),
|
|
|
|
|
("Close", "Zavřít"),
|
2023-09-08 11:53:08 +02:00
|
|
|
("Save changes", "Uložit změny"),
|
|
|
|
|
("Company info", "Organizace"),
|
|
|
|
|
("Name cannot be empty", "Jméno nesmí být prázdné"),
|
2023-09-27 11:36:52 +02:00
|
|
|
("Invalid old password", "Neplatné staré heslo"),
|
|
|
|
|
("Please sign-in to your account", "Přihlaste se prosím k uživatelskému účtu"),
|
2023-08-18 12:22:23 +02:00
|
|
|
])),
|
|
|
|
|
("sk", HashMap::from( [
|
|
|
|
|
("Dashboard", "Prehlad"),
|
|
|
|
|
("Settings", "Nastavenie"),
|
|
|
|
|
("Search...", "Najsť...")
|
|
|
|
|
]))
|
|
|
|
|
]);
|
|
|
|
|
m
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-15 13:55:01 +02:00
|
|
|
pub fn get_dictionary() -> Option<&'static HashMap<&'static str, &'static str>> {
|
2023-09-18 13:10:59 +02:00
|
|
|
let locs = use_context::<Locales>().unwrap_or(Locales(vec![])).0;
|
2023-08-18 12:22:23 +02:00
|
|
|
for loc in locs {
|
|
|
|
|
if let Some(key) = loc {
|
|
|
|
|
if let Some(k) = key.split("-").collect::<Vec<_>>().get(0) {
|
|
|
|
|
if *k == "en" {
|
|
|
|
|
return None;
|
|
|
|
|
}
|
|
|
|
|
if !LANGUAGES.contains_key(*k) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
return LANGUAGES.get(*k);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
None
|
|
|
|
|
}
|