fix(web): validate stored language against supported locales

Drop the dead zh-CN/zh-TW Element locale imports, resolve any stored
language only when it is in supportedLanguages (else fall back to en),
and generalize the language-code tooltip example from zh-CN to en-US.
This commit is contained in:
lapy 2026-10-11 17:58:09 +01:00
parent e786e948ec
commit 302ed23055
2 changed files with 12 additions and 13 deletions

View file

@ -6,7 +6,7 @@ export default {
'login.requiredMobile': 'Please enter a valid mobile phone number', 'login.requiredMobile': 'Please enter a valid mobile phone number',
'login.loginSuccess': 'Login successful!', 'login.loginSuccess': 'Login successful!',
// HeaderBar组件文本 // HeaderBar component text
'header.smartManagement': 'Agents', 'header.smartManagement': 'Agents',
'header.modelConfig': 'Models', 'header.modelConfig': 'Models',
'header.knowledgeBase': 'Knowledge', 'header.knowledgeBase': 'Knowledge',
@ -17,7 +17,7 @@ export default {
'header.paramDictionary': 'More', 'header.paramDictionary': 'More',
'header.paramManagement': 'Params Management', 'header.paramManagement': 'Params Management',
'header.dictManagement': 'Dict Management', 'header.dictManagement': 'Dict Management',
'header.agentTemplate': 'Default Role Templates', // 添加这一行 'header.agentTemplate': 'Default Role Templates', // Add this line
'header.searchHistory': 'Search History', 'header.searchHistory': 'Search History',
'header.clearHistory': 'Clear History', 'header.clearHistory': 'Clear History',
'header.providerManagement': 'Provider Management', 'header.providerManagement': 'Provider Management',
@ -31,10 +31,10 @@ export default {
// McpToolCallDialog component text // McpToolCallDialog component text
'mcpToolCall.title': 'Tool Call', 'mcpToolCall.title': 'Tool Call',
'mcpToolCall.execute': 'Execute', 'mcpToolCall.execute': 'Execute',
'mcpToolCall.chooseFunction': '1、Choose Function', 'mcpToolCall.chooseFunction': '1,Choose Function',
'mcpToolCall.searchFunction': 'Search Function', 'mcpToolCall.searchFunction': 'Search Function',
'mcpToolCall.noResults': 'No matching functions found', 'mcpToolCall.noResults': 'No matching functions found',
'mcpToolCall.settings': '2、Parameter Settings', 'mcpToolCall.settings': '2,Parameter Settings',
'mcpToolCall.inputPlaceholder': 'Please enter {label}', 'mcpToolCall.inputPlaceholder': 'Please enter {label}',
'mcpToolCall.valueRange': 'Value range: {min} - {max}', 'mcpToolCall.valueRange': 'Value range: {min} - {max}',
'mcpToolCall.selectPlaceholder': 'Please select {label}', 'mcpToolCall.selectPlaceholder': 'Please select {label}',
@ -46,7 +46,7 @@ export default {
'mcpToolCall.minValue': 'Minimum value is {value}', 'mcpToolCall.minValue': 'Minimum value is {value}',
'mcpToolCall.maxValue': 'Maximum value is {value}', 'mcpToolCall.maxValue': 'Maximum value is {value}',
'mcpToolCall.selectTool': 'Please select a tool to execute', 'mcpToolCall.selectTool': 'Please select a tool to execute',
'mcpToolCall.executionResult': '3、Execution Result', 'mcpToolCall.executionResult': '3,Execution Result',
'mcpToolCall.copyResult': 'Copy Result', 'mcpToolCall.copyResult': 'Copy Result',
'mcpToolCall.noResultYet': 'No result yet', 'mcpToolCall.noResultYet': 'No result yet',
'mcpToolCall.loadingToolList': 'Loading tool list...', 'mcpToolCall.loadingToolList': 'Loading tool list...',
@ -714,8 +714,8 @@ export default {
'common.copyAddress': 'Copy address', 'common.copyAddress': 'Copy address',
// Language switch // Language switch
'language.zhCN': '中文简体', 'language.zhCN': 'Simplified Chinese',
'language.zhTW': '中文繁體', 'language.zhTW': 'Traditional Chinese',
'language.en': 'English', 'language.en': 'English',
'language.de': 'Deutsch', 'language.de': 'Deutsch',
'language.vi': 'Tiếng Việt', 'language.vi': 'Tiếng Việt',
@ -1011,7 +1011,7 @@ export default {
'roleConfig.tooltip.contextProvider': 'When XiaoZhi is awakened, fetch external system data and dynamically inject it into the LLM system prompt', 'roleConfig.tooltip.contextProvider': 'When XiaoZhi is awakened, fetch external system data and dynamically inject it into the LLM system prompt',
'roleConfig.tooltip.roleIntroduction': 'Define the AI agent\'s role positioning, personality traits, behavioral norms, and professional knowledge background', 'roleConfig.tooltip.roleIntroduction': 'Define the AI agent\'s role positioning, personality traits, behavioral norms, and professional knowledge background',
'roleConfig.tooltip.memoryHis': 'Summarize chat record content', 'roleConfig.tooltip.memoryHis': 'Summarize chat record content',
'roleConfig.tooltip.languageCode': 'Set language code such as zh-CN, en-US, etc., used for specific feature recognition', 'roleConfig.tooltip.languageCode': 'Set a BCP-47 language code such as en-US, used for specific feature recognition',
'roleConfig.tooltip.interactionLanguage': 'Set the interaction language, specifying the primary language the AI agent uses for communication', 'roleConfig.tooltip.interactionLanguage': 'Set the interaction language, specifying the primary language the AI agent uses for communication',
'roleConfig.tooltip.vad': 'Voice Activity Detection: Detects when the user starts or stops speaking, used to determine conversation start and end, enabling interrupt functionality', 'roleConfig.tooltip.vad': 'Voice Activity Detection: Detects when the user starts or stops speaking, used to determine conversation start and end, enabling interrupt functionality',
'roleConfig.tooltip.asr': 'Automatic Speech Recognition: Converts user speech to text, the first step in human-computer dialogue, supporting multilingual recognition', 'roleConfig.tooltip.asr': 'Automatic Speech Recognition: Converts user speech to text, the first step in human-computer dialogue, supporting multilingual recognition',

View file

@ -6,8 +6,6 @@ import vi from './vi';
import ptBR from './pt_BR'; import ptBR from './pt_BR';
import enLocale from 'element-ui/lib/locale/lang/en' import enLocale from 'element-ui/lib/locale/lang/en'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
import twLocale from 'element-ui/lib/locale/lang/zh-TW'
import deLocale from 'element-ui/lib/locale/lang/de' import deLocale from 'element-ui/lib/locale/lang/de'
import viLocale from 'element-ui/lib/locale/lang/vi' import viLocale from 'element-ui/lib/locale/lang/vi'
import ptBRLocale from 'element-ui/lib/locale/lang/pt-br' import ptBRLocale from 'element-ui/lib/locale/lang/pt-br'
@ -31,10 +29,11 @@ export const getLanguageLabelKey = (lang) => {
const getDefaultLanguage = () => { const getDefaultLanguage = () => {
const savedLang = localStorage.getItem('userLanguage'); const savedLang = localStorage.getItem('userLanguage');
if (savedLang) { if (savedLang) {
if (savedLang === 'zh_CN' || savedLang === 'zh_TW') { // Legacy installs may have stored a language this fork no longer ships.
return 'en'; if (supportedLanguages.some((item) => item.code === savedLang)) {
return savedLang;
} }
return savedLang; return 'en';
} }
const browserLang = navigator.language || navigator.userLanguage; const browserLang = navigator.language || navigator.userLanguage;
if (browserLang.indexOf('de') === 0) { if (browserLang.indexOf('de') === 0) {