Fixed localization.

This commit is contained in:
2023-09-18 13:10:59 +02:00
parent a2a4c551b4
commit 0bac17f2eb
4 changed files with 26 additions and 24 deletions
+18 -1
View File
@@ -1,10 +1,27 @@
use std::borrow::Cow;
use std::ops::Deref;
use leptos::*;
use crate::locales::catalogues::get_dictionary;
mod catalogues;
#[derive(Debug, Clone)]
pub struct Locales(pub Vec<Option<String>>);
pub fn init_locales() {
#[cfg(not(feature = "ssr"))]
{
let loc = Locales(
window()
.navigator()
.languages()
.into_iter()
.map(|val| val.as_string())
.collect::<Vec<_>>(),
);
provide_context(loc);
}
}
pub fn trl(phrase: &str) -> impl Fn() -> String {
let mut translated = phrase;
if let Some(dict) = get_dictionary() {