Multilingual support via Fluent + Frontend improvements + Rewrite of ArcReactor

This commit is contained in:
Priler 2026-01-07 05:04:04 +05:00
parent adec595cfa
commit 412acb7e2d
41 changed files with 2436 additions and 723 deletions

View file

@ -15,6 +15,7 @@ pub fn db_read(state: tauri::State<'_, AppState>, key: &str) -> String {
"noise_suppression" => format!("{:?}", settings.noise_suppression),
"vad" => format!("{:?}", settings.vad),
"gain_normalizer" => settings.gain_normalizer.to_string(),
"language" => settings.language.to_string(),
"api_key__picovoice" => settings.api_keys.picovoice.clone(),
"api_key__openai" => settings.api_keys.openai.clone(),
_ => String::new(),
@ -78,6 +79,9 @@ pub fn db_write(state: tauri::State<'_, AppState>, key: &str, val: &str) -> bool
_ => return false,
}
}
"language" => {
settings.language = val.to_string();
}
"api_key__picovoice" => {
settings.api_keys.picovoice = val.to_string();
}

View file

@ -38,6 +38,24 @@ pub fn get_tg_official_link() -> String {
}
}
#[tauri::command]
pub fn get_boosty_link() -> String {
if let Some(ver) = config::SUPPORT_BOOSTY_LINK {
ver.to_string()
} else {
String::from("error")
}
}
#[tauri::command]
pub fn get_patreon_link() -> String {
if let Some(ver) = config::SUPPORT_PATREON_LINK {
ver.to_string()
} else {
String::from("error")
}
}
#[tauri::command]
pub fn get_feedback_link() -> String {
if let Some(res) = config::FEEDBACK_LINK {

View file

@ -0,0 +1,49 @@
use jarvis_core::i18n;
use std::collections::HashMap;
use crate::AppState;
// Get all translations for frontend
#[tauri::command]
pub fn get_translations() -> HashMap<String, String> {
i18n::get_all_translations()
}
// Get single translation
#[tauri::command]
pub fn translate(key: &str) -> String {
i18n::t(key)
}
// Get current language
#[tauri::command]
pub fn get_current_language() -> String {
i18n::get_language()
}
// Set language and get new translations
#[tauri::command]
pub fn set_language(state: tauri::State<'_, AppState>, lang: &str) -> HashMap<String, String> {
// update i18n
i18n::set_language(lang);
// also save to db
{
let mut settings = state.db.write();
settings.language = lang.to_string();
}
// save to disk
let snapshot = state.db.read().clone();
if let Err(e) = jarvis_core::db::save_settings(&snapshot) {
log::error!("Failed to save settings: {}", e);
}
// return new translations
i18n::get_all_translations()
}
// Get supported languages
#[tauri::command]
pub fn get_supported_languages() -> Vec<&'static str> {
i18n::SUPPORTED_LANGUAGES.to_vec()
}