Leptos updated to 0.5
This commit is contained in:
@@ -24,10 +24,10 @@ lazy_static! {
|
||||
};
|
||||
}
|
||||
|
||||
fn get_locales(cx: Scope) -> Vec<Option<String>> {
|
||||
let (loc, set_loc) = create_signal(cx, Vec::new());
|
||||
fn get_locales() -> Vec<Option<String>> {
|
||||
let (loc, set_loc) = create_signal(Vec::new());
|
||||
|
||||
create_effect(cx, move |_| {
|
||||
create_effect(move |_| {
|
||||
let js_locales = window().navigator().languages();
|
||||
set_loc.update(|l| *l = js_locales.into_iter().map(|val| val.as_string()).collect::<Vec<_>>());
|
||||
});
|
||||
@@ -35,8 +35,8 @@ fn get_locales(cx: Scope) -> Vec<Option<String>> {
|
||||
loc.get_untracked()
|
||||
}
|
||||
|
||||
pub fn get_dictionary(cx: Scope) -> Option<&'static HashMap<&'static str, &'static str>> {
|
||||
let locs = get_locales(cx);
|
||||
pub fn get_dictionary() -> Option<&'static HashMap<&'static str, &'static str>> {
|
||||
let locs = get_locales();
|
||||
|
||||
for loc in locs {
|
||||
if let Some(key) = loc {
|
||||
|
||||
+2
-2
@@ -5,9 +5,9 @@ use crate::locales::catalogues::get_dictionary;
|
||||
|
||||
mod catalogues;
|
||||
|
||||
pub fn trl(cx: Scope, phrase: &str) -> impl Fn() -> String {
|
||||
pub fn trl(phrase: &str) -> impl Fn() -> String {
|
||||
let mut translated = phrase;
|
||||
if let Some(dict) = get_dictionary(cx) {
|
||||
if let Some(dict) = get_dictionary() {
|
||||
if let Some(p) = dict.get(phrase.to_string().as_str()) {
|
||||
translated = *p;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user