feat(i18n): bind web language switch to cow_lang config

This commit is contained in:
zhayujie
2026-05-31 17:01:43 +08:00
parent fcf4eb78dc
commit 1827a2a31c
5 changed files with 103 additions and 2 deletions

View File

@@ -1535,6 +1535,7 @@ class ConfigHandler:
])
EDITABLE_KEYS = {
"cow_lang",
"model", "bot_type", "use_linkai",
"open_ai_api_base", "deepseek_api_base", "qianfan_api_base", "claude_api_base", "gemini_api_base",
"zhipu_ai_api_base", "moonshot_base_url", "ark_base_url", "custom_api_base", "mimo_api_base",
@@ -1643,6 +1644,15 @@ class ConfigHandler:
logger.info(f"[WebChannel] Config updated: {list(applied.keys())}")
# Apply a language change immediately so backend logs, agent
# replies and CLI output switch without a restart.
if "cow_lang" in applied:
try:
i18n.resolve_language(applied["cow_lang"])
logger.info(f"[WebChannel] Language switched to: {i18n.get_language()}")
except Exception as lang_err:
logger.warning(f"[WebChannel] Failed to apply language: {lang_err}")
# Reset Bridge so that bot routing reflects the new config.
# Without this, Bridge keeps its cached bot instance (e.g. LinkAIBot)
# even after the user switches bot_type / use_linkai / model in UI.