feat(i18n): complete zh-CN hardening and locale consistency

This commit is contained in:
vansour
2026-04-14 17:14:01 +00:00
committed by Nathan Esquenazi
parent 6a513f49b2
commit c4efe96725
7 changed files with 888 additions and 150 deletions

View File

@@ -290,6 +290,118 @@ const LOCALES = {
onboarding_error_workspace_required: 'Workspace is required.',
onboarding_error_model_required: 'Model is required.',
onboarding_complete: 'Onboarding complete',
// panel/runtime i18n
error_prefix: 'Error: ',
not_available: 'N/A',
never: 'never',
add: 'Add',
add_failed: 'Add failed: ',
remove_failed: 'Remove failed: ',
switch_failed: 'Switch failed: ',
name_required: 'Name is required',
content_required: 'Content is required',
view: 'View',
dismiss: 'Dismiss',
disable: 'Disable',
cron_no_jobs: 'No scheduled jobs found.',
cron_status_off: 'off',
cron_status_paused: 'paused',
cron_status_error: 'error',
cron_status_active: 'active',
cron_next: 'Next',
cron_last: 'Last',
cron_run_now: 'Run now',
cron_pause: 'Pause',
cron_resume: 'Resume',
cron_job_name_placeholder: 'Job name',
cron_schedule_placeholder: 'Schedule',
cron_prompt_placeholder: 'Prompt',
cron_last_output: 'Last output',
cron_all_runs: 'All runs',
cron_hide_runs: 'Hide runs',
cron_no_runs_yet: '(no runs yet)',
cron_schedule_required_example: 'Schedule is required (e.g. "0 9 * * *" or "every 1h")',
cron_schedule_required: 'Schedule is required',
cron_prompt_required: 'Prompt is required',
cron_job_created: 'Job created',
cron_job_triggered: 'Job triggered',
cron_job_paused: 'Job paused',
cron_job_resumed: 'Job resumed',
cron_job_updated: 'Job updated',
cron_delete_confirm_title: 'Delete cron job',
cron_delete_confirm_message: 'This cannot be undone.',
cron_job_deleted: 'Job deleted',
cron_completion_status: (name, status) => `Cron "${name}" ${status}`,
status_failed: 'failed',
status_completed: 'completed',
todos_no_active: 'No active task list in this session.',
clear_conversation_title: 'Clear conversation',
clear_conversation_message: 'Clear all messages? This cannot be undone.',
clear_failed: 'Clear failed: ',
skills_no_match: 'No skills match.',
linked_files: 'Linked Files',
skill_load_failed: 'Could not load skill: ',
skill_file_load_failed: 'Could not load file: ',
skill_name_required: 'Skill name is required',
skill_updated: 'Skill updated',
skill_created: 'Skill created',
memory_notes_label: 'memory (notes)',
memory_saved: 'Memory saved',
my_notes: 'My Notes',
user_profile: 'User Profile',
no_notes_yet: 'No notes yet.',
no_profile_yet: 'No profile yet.',
workspace_choose_path: 'Choose workspace path',
workspace_choose_path_meta: 'Add a validated path and switch this conversation',
workspace_manage: 'Manage workspaces',
workspace_manage_meta: 'Open the Spaces panel',
workspace_use_title: 'Use in current session',
workspace_use: 'Use',
workspace_add_path_placeholder: 'Add workspace path (e.g. /home/user/my-project)',
workspace_paths_validated_hint: 'Paths are validated as existing directories before saving.',
workspace_added: 'Workspace added',
workspace_remove_confirm_title: 'Remove workspace',
workspace_remove_confirm_message: (path) => `Remove "${path}"?`,
workspace_removed: 'Workspace removed',
workspace_switch_prompt_title: 'Switch workspace',
workspace_switch_prompt_message: 'Enter an absolute workspace path to add and switch this conversation to.',
workspace_switch_prompt_confirm: 'Switch',
workspace_switch_prompt_placeholder: '/Users/you/project',
workspace_not_added: 'Workspace was not added',
workspace_already_saved: 'Workspace already saved — choose it from the list',
workspace_busy_switch: 'Cannot switch workspace while agent is running',
discard_file_edits_title: 'Discard file edits?',
discard_file_edits_message: 'Switching workspaces will discard unsaved file edits in the preview.',
workspace_switched_to: (name) => `Switched to ${name}`,
profiles_no_profiles: 'No profiles found.',
profile_api_keys_configured: 'API keys configured',
profile_gateway_running: 'Gateway running',
profile_gateway_stopped: 'Gateway stopped',
profile_active: 'ACTIVE',
profile_no_configuration: 'No configuration',
profile_use: 'Use',
profile_switch_title: 'Switch to this profile',
manage_profiles: 'Manage profiles',
profiles_load_failed: 'Failed to load profiles',
profiles_busy_switch: 'Cannot switch profiles while agent is running',
profile_switched_new_conversation: (name) => `Switched to profile: ${name} — new conversation started`,
profile_switched: (name) => `Switched to profile: ${name}`,
profile_name_rule: 'Lowercase letters, numbers, hyphens, underscores only',
profile_base_url_rule: 'Base URL must start with http:// or https://',
profile_created: (name) => `Profile created: ${name}`,
profile_delete_confirm_title: (name) => `Delete profile "${name}"?`,
profile_delete_confirm_message: 'This removes all config, skills, memory, and sessions for this profile.',
profile_deleted: (name) => `Profile deleted: ${name}`,
active_conversation_none: 'No active conversation selected.',
active_conversation_meta: (title, count) => `${title} · ${count} message${count === 1 ? '' : 's'}`,
settings_unsaved_changes: 'You have unsaved changes.',
sign_out_failed: 'Sign out failed: ',
disable_auth_confirm_title: 'Disable password protection',
disable_auth_confirm_message: 'Anyone will be able to access this instance.',
auth_disabled: 'Auth disabled — password protection removed',
disable_auth_failed: 'Failed to disable auth: ',
bg_error_single: (title) => `"${title}" has encountered an error`,
bg_error_multi: (count) => `${count} sessions have encountered an error`,
},
es: {
@@ -570,6 +682,118 @@ const LOCALES = {
onboarding_error_workspace_required: 'El espacio de trabajo es obligatorio.',
onboarding_error_model_required: 'El modelo es obligatorio.',
onboarding_complete: 'Onboarding completado',
// panel/runtime i18n
error_prefix: 'Error: ',
not_available: 'N/A',
never: 'never',
add: 'Add',
add_failed: 'Add failed: ',
remove_failed: 'Remove failed: ',
switch_failed: 'Switch failed: ',
name_required: 'Name is required',
content_required: 'Content is required',
view: 'View',
dismiss: 'Dismiss',
disable: 'Disable',
cron_no_jobs: 'No scheduled jobs found.',
cron_status_off: 'off',
cron_status_paused: 'paused',
cron_status_error: 'error',
cron_status_active: 'active',
cron_next: 'Next',
cron_last: 'Last',
cron_run_now: 'Run now',
cron_pause: 'Pause',
cron_resume: 'Resume',
cron_job_name_placeholder: 'Job name',
cron_schedule_placeholder: 'Schedule',
cron_prompt_placeholder: 'Prompt',
cron_last_output: 'Last output',
cron_all_runs: 'All runs',
cron_hide_runs: 'Hide runs',
cron_no_runs_yet: '(no runs yet)',
cron_schedule_required_example: 'Schedule is required (e.g. "0 9 * * *" or "every 1h")',
cron_schedule_required: 'Schedule is required',
cron_prompt_required: 'Prompt is required',
cron_job_created: 'Job created',
cron_job_triggered: 'Job triggered',
cron_job_paused: 'Job paused',
cron_job_resumed: 'Job resumed',
cron_job_updated: 'Job updated',
cron_delete_confirm_title: 'Delete cron job',
cron_delete_confirm_message: 'This cannot be undone.',
cron_job_deleted: 'Job deleted',
cron_completion_status: (name, status) => `Cron "${name}" ${status}`,
status_failed: 'failed',
status_completed: 'completed',
todos_no_active: 'No active task list in this session.',
clear_conversation_title: 'Clear conversation',
clear_conversation_message: 'Clear all messages? This cannot be undone.',
clear_failed: 'Clear failed: ',
skills_no_match: 'No skills match.',
linked_files: 'Linked Files',
skill_load_failed: 'Could not load skill: ',
skill_file_load_failed: 'Could not load file: ',
skill_name_required: 'Skill name is required',
skill_updated: 'Skill updated',
skill_created: 'Skill created',
memory_notes_label: 'memory (notes)',
memory_saved: 'Memory saved',
my_notes: 'My Notes',
user_profile: 'User Profile',
no_notes_yet: 'No notes yet.',
no_profile_yet: 'No profile yet.',
workspace_choose_path: 'Choose workspace path',
workspace_choose_path_meta: 'Add a validated path and switch this conversation',
workspace_manage: 'Manage workspaces',
workspace_manage_meta: 'Open the Spaces panel',
workspace_use_title: 'Use in current session',
workspace_use: 'Use',
workspace_add_path_placeholder: 'Add workspace path (e.g. /home/user/my-project)',
workspace_paths_validated_hint: 'Paths are validated as existing directories before saving.',
workspace_added: 'Workspace added',
workspace_remove_confirm_title: 'Remove workspace',
workspace_remove_confirm_message: (path) => `Remove "${path}"?`,
workspace_removed: 'Workspace removed',
workspace_switch_prompt_title: 'Switch workspace',
workspace_switch_prompt_message: 'Enter an absolute workspace path to add and switch this conversation to.',
workspace_switch_prompt_confirm: 'Switch',
workspace_switch_prompt_placeholder: '/Users/you/project',
workspace_not_added: 'Workspace was not added',
workspace_already_saved: 'Workspace already saved — choose it from the list',
workspace_busy_switch: 'Cannot switch workspace while agent is running',
discard_file_edits_title: 'Discard file edits?',
discard_file_edits_message: 'Switching workspaces will discard unsaved file edits in the preview.',
workspace_switched_to: (name) => `Switched to ${name}`,
profiles_no_profiles: 'No profiles found.',
profile_api_keys_configured: 'API keys configured',
profile_gateway_running: 'Gateway running',
profile_gateway_stopped: 'Gateway stopped',
profile_active: 'ACTIVE',
profile_no_configuration: 'No configuration',
profile_use: 'Use',
profile_switch_title: 'Switch to this profile',
manage_profiles: 'Manage profiles',
profiles_load_failed: 'Failed to load profiles',
profiles_busy_switch: 'Cannot switch profiles while agent is running',
profile_switched_new_conversation: (name) => `Switched to profile: ${name} — new conversation started`,
profile_switched: (name) => `Switched to profile: ${name}`,
profile_name_rule: 'Lowercase letters, numbers, hyphens, underscores only',
profile_base_url_rule: 'Base URL must start with http:// or https://',
profile_created: (name) => `Profile created: ${name}`,
profile_delete_confirm_title: (name) => `Delete profile "${name}"?`,
profile_delete_confirm_message: 'This removes all config, skills, memory, and sessions for this profile.',
profile_deleted: (name) => `Profile deleted: ${name}`,
active_conversation_none: 'No active conversation selected.',
active_conversation_meta: (title, count) => `${title} · ${count} message${count === 1 ? '' : 's'}`,
settings_unsaved_changes: 'You have unsaved changes.',
sign_out_failed: 'Sign out failed: ',
disable_auth_confirm_title: 'Disable password protection',
disable_auth_confirm_message: 'Anyone will be able to access this instance.',
auth_disabled: 'Auth disabled — password protection removed',
disable_auth_failed: 'Failed to disable auth: ',
bg_error_single: (title) => `"${title}" has encountered an error`,
bg_error_multi: (count) => `${count} sessions have encountered an error`,
},
de: {
@@ -898,6 +1122,7 @@ const LOCALES = {
settings_label_theme: '\u4e3b\u9898',
settings_label_language: '\u8bed\u8a00',
settings_label_token_usage: '\u663e\u793a token \u7528\u91cf',
settings_label_bubble_layout: '聊天气泡布局',
settings_label_cli_sessions: '\u663e\u793a CLI \u4f1a\u8bdd',
settings_label_sync_insights: '\u540c\u6b65\u5230 insights',
settings_label_check_updates: '\u68c0\u67e5\u66f4\u65b0',
@@ -921,8 +1146,20 @@ const LOCALES = {
tab_tasks: '任务',
tab_todos: '待办',
tab_workspaces: '工作区',
tab_profiles: '配置',
new_conversation: '新建对话',
filter_conversations: '筛选对话…',
session_time_unknown: '未知',
session_time_just_now: '刚刚',
session_time_minutes_ago: (n) => `${n} 分钟前`,
session_time_hours_ago: (n) => `${n} 小时前`,
session_time_days_ago: (n) => `${n} 天前`,
session_time_last_week: '上周',
session_time_bucket_today: '今天',
session_time_bucket_yesterday: '昨天',
session_time_bucket_this_week: '本周',
session_time_bucket_last_week: '上周',
session_time_bucket_older: '更早',
scheduled_jobs: '定时任务',
new_job: '新任务',
search_skills: '搜索技能…',
@@ -930,6 +1167,7 @@ const LOCALES = {
save_skill: '保存技能',
personal_memory: '个人记忆',
current_task_list: '当前任务列表',
workspace_desc: '为你的会话添加并切换工作区。',
new_profile: '新配置',
transcript: '记录',
download_transcript: '下载为 Markdown',
@@ -951,11 +1189,198 @@ const LOCALES = {
settings_desc_sound: '助手完成回复时播放提示音。',
settings_desc_notifications: '当标签页在后台时,回复完成后显示系统通知。',
settings_desc_token_usage: '在助手每次回复下方显示输入/输出 token 数量。也可以用 /usage 切换。',
settings_desc_bubble_layout: '开启后将用户消息右对齐、助手消息左对齐。默认关闭,以保持代码块和工具输出为全宽显示。',
settings_desc_cli_sessions: '将 Hermes CLIstate.db中的会话合并到会话列表。点击某个 CLI 会话可导入并继续对话。',
settings_desc_sync_insights: '将 WebUI token 使用情况同步到 state.db使 hermes /insights 包含浏览器会话数据。默认关闭。',
settings_desc_check_updates: '当有更新的 WebUI 或助手版本时显示横幅。会在后台定期执行 git fetch。',
settings_desc_bot_name: '助手在 UI 中的显示名称。默认为 Hermes。',
settings_desc_password: '输入新密码以设置或更改。留空保持当前设置。',
// onboarding
onboarding_badge: '首次运行',
onboarding_title: '欢迎使用 Hermes Web UI',
onboarding_lead: '快速引导将验证 Hermes、保存真实的提供商配置、选择工作区和模型并可选设置密码保护应用。',
onboarding_back: '返回',
onboarding_continue: '继续',
onboarding_open: '打开 Hermes',
onboarding_step_system_title: '系统检查',
onboarding_step_system_desc: '验证 Hermes Agent 与配置可见性。',
onboarding_step_setup_title: '提供商设置',
onboarding_step_setup_desc: '保存最小可用的 Hermes 提供商配置。',
onboarding_step_workspace_title: '工作区 + 模型',
onboarding_step_workspace_desc: '为新会话和聊天选择默认值。',
onboarding_step_password_title: '可选密码',
onboarding_step_password_desc: '在分享前为 Web UI 添加保护。',
onboarding_step_finish_title: '完成',
onboarding_step_finish_desc: '确认信息并进入应用。',
onboarding_notice_system_ready: 'Hermes Agent 看起来可从 Web UI 访问。',
onboarding_notice_system_unavailable: 'Hermes Agent 尚未完全可用。Bootstrap 可以安装它,但提供商设置可能仍需要终端。',
onboarding_check_agent: 'Hermes Agent',
onboarding_check_agent_ready: '已检测且可导入',
onboarding_check_agent_missing: '缺失或仅部分可导入',
onboarding_check_password: '密码',
onboarding_check_password_enabled: '已启用',
onboarding_check_password_disabled: '尚未启用',
onboarding_check_provider: '提供商配置',
onboarding_check_provider_ready: '可开始聊天',
onboarding_check_provider_partial: '已保存但不完整',
onboarding_check_provider_pending: '需要验证',
onboarding_config_file: '配置文件:',
onboarding_env_file: '.env 文件:',
onboarding_unknown: '未知',
onboarding_current_provider: '当前配置:',
onboarding_missing_imports: '缺失导入:',
onboarding_notice_setup_required: '请先在此选择一个简单的提供商路径。高级 OAuth 流程暂时仍建议在 Hermes CLI 中完成。',
onboarding_notice_setup_already_ready: '已检测到可用的 Hermes 提供商配置。你可以保留它,或在这里替换。',
onboarding_oauth_provider_ready_title: '提供商已完成认证',
onboarding_oauth_provider_ready_body: '此实例已配置为使用通过 Hermes CLI 设置的 OAuth 提供商(<strong>{provider}</strong>)。这里不需要 API key点击继续即可完成设置。',
onboarding_oauth_provider_not_ready_title: 'OAuth 提供商尚未认证',
onboarding_oauth_provider_not_ready_body: '此实例已配置为使用 <strong>{provider}</strong>,该提供商使用 OAuth 而非 API key。请在终端运行 <code>hermes auth</code> 或 <code>hermes model</code> 完成认证,然后重新加载 Web UI。',
onboarding_oauth_switch_hint: '或者在下方选择其他提供商,切换到 API key 配置:',
onboarding_notice_workspace: '这些值复用与正式应用相同的设置 API。',
onboarding_workspace_label: '工作区',
onboarding_workspace_or_path: '或输入工作区路径',
onboarding_workspace_placeholder: '/home/you/workspace',
onboarding_provider_label: '设置模式',
onboarding_quick_setup_badge: '快速设置',
onboarding_api_key_label: 'API key',
onboarding_api_key_placeholder: '留空可保留已保存的 key',
onboarding_api_key_help_prefix: '会作为密钥保存到 Hermes .env 文件中,变量名为',
onboarding_base_url_label: 'Base URL',
onboarding_base_url_placeholder: 'https://your-endpoint.example/v1',
onboarding_base_url_help: '用于 OpenAI 兼容路由、自托管服务、LiteLLM、Ollama、LM Studio、vLLM 或类似端点。',
onboarding_model_label: '默认模型',
onboarding_workspace_help: '选择设置完成后 Hermes 在新聊天中使用的模型。',
onboarding_custom_model_placeholder: 'your-model-name',
onboarding_custom_model_help: '对于自定义端点,请填写服务端要求的精确模型 ID。',
onboarding_notice_password_enabled: '已配置密码。仅在你想替换时输入新密码。',
onboarding_notice_password_recommended: '可选,但如果你会把 UI 暴露到 localhost 之外,建议设置。',
onboarding_password_label: '密码(可选)',
onboarding_password_placeholder: '留空则跳过',
onboarding_password_help: '密码通过现有设置 API 保存,并在服务端进行哈希处理。',
onboarding_notice_finish: '你之后仍可在设置中修改这些选项。',
onboarding_not_set: '未设置',
onboarding_password_will_enable: '将启用',
onboarding_password_skipped: '暂时跳过',
onboarding_finish_help: '完成后会在设置中写入 <code>onboarding_completed</code>,并进入常规应用界面。',
onboarding_error_choose_workspace: '继续前请先选择工作区。',
onboarding_error_choose_model: '继续前请先选择模型。',
onboarding_error_provider_required: '继续前请先选择设置模式。',
onboarding_error_base_url_required: '自定义端点必须填写 Base URL。',
onboarding_error_workspace_required: '必须填写工作区。',
onboarding_error_model_required: '必须填写模型。',
onboarding_complete: '引导完成',
// panel/runtime i18n
error_prefix: '错误:',
not_available: '无',
never: '从未',
add: '添加',
add_failed: '添加失败:',
remove_failed: '移除失败:',
switch_failed: '切换失败:',
name_required: '名称不能为空',
content_required: '内容不能为空',
view: '查看',
dismiss: '忽略',
disable: '停用',
cron_no_jobs: '未找到定时任务。',
cron_status_off: '关闭',
cron_status_paused: '暂停',
cron_status_error: '错误',
cron_status_active: '运行中',
cron_next: '下次',
cron_last: '上次',
cron_run_now: '立即运行',
cron_pause: '暂停',
cron_resume: '恢复',
cron_job_name_placeholder: '任务名称',
cron_schedule_placeholder: '调度表达式',
cron_prompt_placeholder: '提示词',
cron_last_output: '最近输出',
cron_all_runs: '全部运行记录',
cron_hide_runs: '隐藏记录',
cron_no_runs_yet: '(暂无运行记录)',
cron_schedule_required_example: '必须填写调度(例如 "0 9 * * *" 或 "every 1h"',
cron_schedule_required: '必须填写调度',
cron_prompt_required: '必须填写提示词',
cron_job_created: '任务已创建',
cron_job_triggered: '任务已触发',
cron_job_paused: '任务已暂停',
cron_job_resumed: '任务已恢复',
cron_job_updated: '任务已更新',
cron_delete_confirm_title: '删除定时任务',
cron_delete_confirm_message: '此操作无法撤销。',
cron_job_deleted: '任务已删除',
cron_completion_status: (name, status) => `定时任务“${name}${status}`,
status_failed: '失败',
status_completed: '完成',
todos_no_active: '此会话暂无活动任务列表。',
clear_conversation_title: '清空对话',
clear_conversation_message: '要清空所有消息吗?此操作无法撤销。',
clear_failed: '清空失败:',
skills_no_match: '没有匹配的技能。',
linked_files: '关联文件',
skill_load_failed: '加载技能失败:',
skill_file_load_failed: '加载文件失败:',
skill_name_required: '技能名称不能为空',
skill_updated: '技能已更新',
skill_created: '技能已创建',
memory_notes_label: '记忆(备注)',
memory_saved: '记忆已保存',
my_notes: '我的备注',
user_profile: '用户画像',
no_notes_yet: '暂无备注。',
no_profile_yet: '暂无用户画像。',
workspace_choose_path: '选择工作区路径',
workspace_choose_path_meta: '添加已校验路径并切换当前会话',
workspace_manage: '管理工作区',
workspace_manage_meta: '打开 Spaces 面板',
workspace_use_title: '用于当前会话',
workspace_use: '使用',
workspace_add_path_placeholder: '添加工作区路径(例如 /home/user/my-project',
workspace_paths_validated_hint: '保存前会校验路径是否为已存在目录。',
workspace_added: '工作区已添加',
workspace_remove_confirm_title: '移除工作区',
workspace_remove_confirm_message: (path) => `要移除“${path}”吗?`,
workspace_removed: '工作区已移除',
workspace_switch_prompt_title: '切换工作区',
workspace_switch_prompt_message: '输入绝对路径以添加并切换当前会话的工作区。',
workspace_switch_prompt_confirm: '切换',
workspace_switch_prompt_placeholder: '/Users/you/project',
workspace_not_added: '工作区未添加成功',
workspace_already_saved: '工作区已存在,请在列表中选择',
workspace_busy_switch: 'Agent 运行中,无法切换工作区',
discard_file_edits_title: '放弃文件编辑?',
discard_file_edits_message: '切换工作区将丢弃预览区未保存的文件修改。',
workspace_switched_to: (name) => `已切换到 ${name}`,
profiles_no_profiles: '未找到配置档。',
profile_api_keys_configured: '已配置 API 密钥',
profile_gateway_running: '网关运行中',
profile_gateway_stopped: '网关已停止',
profile_active: '当前',
profile_no_configuration: '无配置',
profile_use: '使用',
profile_switch_title: '切换到此配置档',
manage_profiles: '管理配置档',
profiles_load_failed: '加载配置档失败',
profiles_busy_switch: 'Agent 运行中,无法切换配置档',
profile_switched_new_conversation: (name) => `已切换到配置档:${name},并新建对话`,
profile_switched: (name) => `已切换到配置档:${name}`,
profile_name_rule: '仅允许小写字母、数字、连字符和下划线',
profile_base_url_rule: 'Base URL 必须以 http:// 或 https:// 开头',
profile_created: (name) => `配置档已创建:${name}`,
profile_delete_confirm_title: (name) => `删除配置档“${name}”?`,
profile_delete_confirm_message: '这将删除该配置档的所有配置、技能、记忆和会话。',
profile_deleted: (name) => `配置档已删除:${name}`,
active_conversation_none: '当前未选择活动会话。',
active_conversation_meta: (title, count) => `${title} · ${count} 条消息`,
settings_unsaved_changes: '你有未保存的更改。',
sign_out_failed: '退出登录失败:',
disable_auth_confirm_title: '停用密码保护',
disable_auth_confirm_message: '任何人都可以访问此实例。',
auth_disabled: '认证已停用,密码保护已移除',
disable_auth_failed: '停用认证失败:',
bg_error_single: (title) => `${title}”出现错误`,
bg_error_multi: (count) => `${count} 个会话出现错误`,
},
// Traditional Chinese (zh-Hant)
@@ -1144,23 +1569,6 @@ const LOCALES = {
settings_desc_check_updates: '\u7576\u6709\u66f4\u65b0\u7684 WebUI \u6216\u52a9\u624b\u7248\u672c\u6642\u986f\u793a\u6a19\u8a18\u3002\u5c07\u5728\u5f8c\u81ea\u6b63\u5e38\u57f7\u884c Git-Fetch\u3002',
settings_desc_bot_name: '\u52a9\u624b\u5728 UI \u4e2d\u7684\u986f\u793a\u540d\u7a31\u3002\u9810\u8a2d\u70b8\u7528\u6539\u3002',
settings_desc_password: '\u8a2d\u5b9a WebUI \u767b\u5165\u5bc6\u78bc\u3002\u5047\u5982\u5df2\u8a2d\u7f6e\uff0c\u6bcf\u6b21\u52a0\u8f09\u90fd\u9700\u8981\u767b\u5165\u3002',
settings_label_sound: '\u901a\u77e5\u8072\u97f3',
// boot.js
cancelling: '\u6b63\u5728\u53d6\u6d88...',
cancel_failed: '\u53d6\u6d88\u5931\u6557\uff1a',
mic_denied: '\u9ea6\u514b\u98a8\u8a2a\u554f\u88ab\u62d2\u7d75\uff0c\u8acb\u6aa2\u67e5\u700f\u89bd\u5668\u6b0a\u9650\u3002',
mic_no_speech: '\u6c92\u6709\u6aa2\u6e2c\u5230\u8a71\u97f3\uff0c\u8acb\u518d\u5617\u4e00\u6b21\u3002',
mic_network: '\u8a71\u97f3\u8b58\u5225\u76ee\u524d\u4e0d\u53ef\u7528\u3002',
mic_error: '\u8a71\u97f3\u8f38\u5165\u51fa\u932f\uff1a',
session_imported: '\u6703\u8a71\u5df2\u5c0e\u5165',
import_failed: '\u5c0e\u5165\u5931\u6557\uff1a',
import_invalid_json: 'JSON \u7121\u6548',
image_pasted: '\u5df2\u7c98\u8cbc\u5716\u7247\uff1a',
// messages.js
edit_message: '\u7de8\u8f2f\u8a0a\u606f',
regenerate: '\u91cd\u65b0\u751f\u6210\u56de\u8986',
copy: '\u8907\u88fd',
copied: '\u5df2\u8907\u88fd',
// ui.js
workspace_desc: '\u8acb\u9078\u64c7\u5de5\u4f5c\u5340\uff0c\u6216\u8f09\u5165\u65b0\u540d\u7a31\u5beb\u4e00\u500b',
tab_profiles: '\u914d\u7f6e',
@@ -1170,6 +1578,52 @@ const LOCALES = {
// Active locale — defaults to English; overridden by loadLocale() at boot.
let _locale = LOCALES.en;
/**
* Resolve an incoming locale tag to a known LOCALES key.
* Supports exact keys, case-insensitive matches, and a few common aliases
* (e.g. zh-CN -> zh, zh-TW -> zh-Hant). Returns null when unresolved.
* @param {string} lang
* @returns {string|null}
*/
function resolveLocale(lang) {
if (typeof lang !== 'string') return null;
const raw = lang.trim();
if (!raw) return null;
if (LOCALES[raw]) return raw;
const lower = raw.toLowerCase().replace(/_/g, '-');
// Case-insensitive direct match first.
const direct = Object.keys(LOCALES).find((k) => k.toLowerCase() === lower);
if (direct) return direct;
// Common Chinese variants.
if (lower === 'zh' || lower.startsWith('zh-cn') || lower.startsWith('zh-sg') || lower.startsWith('zh-hans')) {
return LOCALES.zh ? 'zh' : null;
}
if (lower.startsWith('zh-tw') || lower.startsWith('zh-hk') || lower.startsWith('zh-mo') || lower.startsWith('zh-hant')) {
return LOCALES['zh-Hant'] ? 'zh-Hant' : null;
}
// Fallback to base language subtag (e.g. en-US -> en).
const base = lower.split('-')[0];
const baseMatch = Object.keys(LOCALES).find((k) => k.toLowerCase() === base);
return baseMatch || null;
}
/**
* Resolve locale with precedence:
* 1) primary (typically server setting)
* 2) fallback (typically localStorage)
* 3) English
* @param {string} primary
* @param {string} fallback
* @returns {string}
*/
function resolvePreferredLocale(primary, fallback) {
return resolveLocale(primary) || resolveLocale(fallback) || 'en';
}
/**
* Translate a key. Falls back to English if the key is missing in the active locale.
* Supports function values (for interpolated strings): call t('key', arg).
@@ -1189,7 +1643,7 @@ function t(key, ...args) {
* @param {string} lang
*/
function setLocale(lang) {
const resolved = LOCALES[lang] ? lang : 'en';
const resolved = resolveLocale(lang) || 'en';
_locale = LOCALES[resolved];
localStorage.setItem('hermes-lang', resolved);
document.documentElement.lang = _locale._speech || resolved;
@@ -1200,8 +1654,7 @@ function setLocale(lang) {
* Server-persisted preference is applied later in loadSettingsPanel().
*/
function loadLocale() {
const saved = localStorage.getItem('hermes-lang');
setLocale(saved && LOCALES[saved] ? saved : 'en');
setLocale(resolvePreferredLocale(null, localStorage.getItem('hermes-lang')));
}
/**