2024-01-15 08:00:56 +13:00
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
use slint::{ComponentHandle, Model};
|
|
|
|
|
2023-12-04 00:06:42 +13:00
|
|
|
use crate::localizer_krokiet::LANGUAGE_LOADER_GUI;
|
|
|
|
use crate::{Callabler, MainWindow};
|
|
|
|
|
|
|
|
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()
|
|
|
|
});
|
|
|
|
}
|