1
0
Fork 0
mirror of synced 2024-06-01 18:19:46 +12:00
czkawka/krokiet/src/connect_translation.rs

23 lines
728 B
Rust
Raw Normal View History

use crate::localizer_krokiet::LANGUAGE_LOADER_GUI;
use crate::{Callabler, MainWindow};
2023-12-04 09:18:31 +13:00
use slint::{ComponentHandle, Model};
use std::collections::HashMap;
pub fn connect_translations(app: &MainWindow) {
app.global::<Callabler>().on_translate(move |text_to_translate, args| {
let text_to_translate = text_to_translate.to_string();
let mut arguments = HashMap::new();
args.iter().for_each(|(key, value)| {
arguments.insert(key.to_string(), value.to_string());
});
if arguments.is_empty() {
LANGUAGE_LOADER_GUI.get(&text_to_translate)
} else {
LANGUAGE_LOADER_GUI.get_args(&text_to_translate, arguments)
}
.into()
});
}