refactor: use one global static collator

This commit is contained in:
2024-09-19 22:12:00 +02:00
parent ecf27baaf0
commit e981775494
2 changed files with 7 additions and 2 deletions

View File

@@ -1,12 +1,17 @@
use std::ops::Deref;
use std::str::FromStr;
use std::sync::Mutex;
use chrono::Locale;
use dioxus::fullstack::once_cell::sync::Lazy;
use dioxus_sdk::i18n::Language;
use feruca::Collator;
use unic_langid_impl::LanguageIdentifier;
const EN_US: &str = include_str!("en_us.json");
const CS_CZ: &str = include_str!("cs_cz.json");
pub(crate) static COLLATOR: Lazy<Mutex<Collator>> = Lazy::new(|| Mutex::new(Collator::default()));
pub(crate) fn get_languages() -> Vec<Language> {
Vec::from([EN_US, CS_CZ]).into_iter().map(|texts| Language::from_str(texts).unwrap()).collect()
}