feat(i18n): localize native tray and app menus

This commit is contained in:
Abeautifulsnow authored and GitHub committed 2026-07-23 19:07:10 +08:00
1 parent b53f700dbe
commit 6115771b34
6 files changed
+219 -15

No files matched your search

+8 -1
View File
@@ -8,7 +8,8 @@ use tauri::{AppHandle, Manager, State, Window};
use super::connection::AppState;
use crate::{
apply_debug_log_level, apply_desktop_settings, hide_main_window_for_close, request_app_close, CloseBehaviorState,
apply_debug_log_level, apply_desktop_settings, hide_main_window_for_close, refresh_native_menus, request_app_close,
AppLocaleState, CloseBehaviorState,
};
const DEVELOPMENT_OPEN_TABS_STATE_KEY: &str = "development_open_tabs";
@@ -57,6 +58,12 @@ pub async fn load_max_agent_turns(state: State<'_, Arc<AppState>>) -> Result<u32
state.storage.load_max_agent_turns().await
}
#[tauri::command]
pub fn set_app_locale(app: AppHandle, locale_state: State<'_, AppLocaleState>, locale: String) -> Result<(), String> {
locale_state.set(locale);
refresh_native_menus(&app).map_err(|err| format!("failed to refresh native menus: {err}"))
}
#[tauri::command]
pub async fn save_max_agent_turns(state: State<'_, Arc<AppState>>, max_agent_turns: u32) -> Result<(), String> {
state.storage.save_max_agent_turns(max_agent_turns).await
+6 -5
View File
@@ -906,12 +906,13 @@ mod tests {
#[cfg(windows)]
use super::first_windows_command_path;
#[cfg(not(windows))]
use super::{bash_login_script, canonical_runtime_path, NodeRuntimeCandidate};
use super::{bash_login_script, NodeRuntimeCandidate};
use super::{
is_mcp_compatible_node_version, mcp_command_for_runtime, mcp_native_binary_path_for, mcp_package,
normalized_reported_path, npm_cli_candidates, parse_minimum_node_version, parse_node_version, prefer_runtime,
prefixed_output_path, require_managed_mcp_command, resolve_managed_mcp_command, stdout_after_shell_marker,
NodeRuntime, NodeVersion, MCP_MIN_NODE_VERSION_REQUIREMENT, MCP_PACKAGE_NAME, SHELL_COMMAND_MARKER,
canonical_runtime_path, is_mcp_compatible_node_version, mcp_command_for_runtime, mcp_native_binary_path_for,
mcp_package, normalized_reported_path, npm_cli_candidates, parse_minimum_node_version, parse_node_version,
prefer_runtime, prefixed_output_path, require_managed_mcp_command, resolve_managed_mcp_command,
stdout_after_shell_marker, NodeRuntime, NodeVersion, MCP_MIN_NODE_VERSION_REQUIREMENT, MCP_PACKAGE_NAME,
SHELL_COMMAND_MARKER,
};
#[cfg(not(windows))]
use super::{shell_command_script, shell_quote};