/** * Minimal zh/en copy for the sidebar. The plugin renders outside the slot * system's locale seat, so it reads the browser language directly (the DSH * locale preference and the browser language agree in practice; both default * from navigator.language anyway). */ const zh = { explorer: '资源管理器', git: '源代码管理', terminal: '终端', editor: '编辑器', newTab: '新建标签页', openExplorer: '资源管理器', openGit: 'Git 面板', newTerminal: '新终端', terminalLimit: '终端数量已达上限 (3)', close: '关闭', collapse: '折叠侧边栏', expand: '展开侧边栏', expandFullscreen: '展开为全屏', restoreFullscreen: '还原宽度', terminalError: '终端连接失败', terminalConnectFailed: '终端多次连接失败', terminalRetry: '重试', preview: '预览', edit: '编辑', refresh: '刷新', save: '保存', saved: '已保存', unsaved: '未保存', saveFailed: '保存失败', truncation: '文件过大,仅显示前 512KB', binary: '二进制文件,无法预览', loading: '加载中…', error: '加载失败', retry: '重试', splitLeft: '向左分栏', splitRight: '向右分栏', splitUp: '向上分栏', splitDown: '向下分栏', notRepo: '当前目录不是 git 仓库', noChanges: '没有变更', stage: '暂存', unstage: '取消暂存', stageAll: '全部暂存', unstageAll: '全部取消暂存', commitPlaceholder: '提交信息 (Ctrl+Enter)', commit: '提交', commitError: '提交失败', branch: '分支', checkoutError: '切换分支失败', history: '历史', changes: '变更', staged: '已暂存', unstaged: '未暂存', produced: '本次产出', producedOpen: '在侧边栏中打开', disconnected: '终端连接断开,重连中…', exited: '终端进程已退出', noSession: '选择一个会话以使用侧边栏', hiddenFiles: '隐藏文件', parent: '上级目录', copied: '已复制', copy: '复制', newFile: '新文件', openEditor: '打开编辑器', gitDetail: '查看变更详情', referenceFile: '@文件', copyRelative: '复制相对地址', copyAbsolute: '复制绝对地址', } const en: Record = { explorer: 'Explorer', git: 'Source Control', terminal: 'Terminal', editor: 'Editor', newTab: 'New tab', openExplorer: 'Explorer', openGit: 'Git panel', newTerminal: 'New terminal', terminalLimit: 'Terminal limit reached (3)', close: 'Close', collapse: 'Collapse sidebar', expand: 'Expand sidebar', expandFullscreen: 'Expand to full width', restoreFullscreen: 'Restore width', terminalError: 'Terminal connection failed', terminalConnectFailed: 'Terminal failed to connect repeatedly', terminalRetry: 'Retry', preview: 'Preview', edit: 'Edit', refresh: 'Refresh', save: 'Save', saved: 'Saved', unsaved: 'Unsaved', saveFailed: 'Save failed', truncation: 'File too large — showing the first 512KB', binary: 'Binary file, preview unavailable', loading: 'Loading…', error: 'Failed to load', retry: 'Retry', splitLeft: 'Split left', splitRight: 'Split right', splitUp: 'Split up', splitDown: 'Split down', notRepo: 'This directory is not a git repository', noChanges: 'No changes', stage: 'Stage', unstage: 'Unstage', stageAll: 'Stage all', unstageAll: 'Unstage all', commitPlaceholder: 'Commit message (Ctrl+Enter)', commit: 'Commit', commitError: 'Commit failed', branch: 'Branch', checkoutError: 'Branch switch failed', history: 'History', changes: 'Changes', staged: 'Staged', unstaged: 'Unstaged', produced: 'Produced', producedOpen: 'Open in sidebar', disconnected: 'Terminal disconnected, reconnecting…', exited: 'Terminal process exited', noSession: 'Select a conversation to use the sidebar', hiddenFiles: 'Hidden files', parent: 'Parent directory', copied: 'Copied', copy: 'Copy', newFile: 'New file', openEditor: 'Open editor', gitDetail: 'View change details', referenceFile: '@file', copyRelative: 'Copy relative path', copyAbsolute: 'Copy absolute path', } /** Translate a copy key in the browser's language (zh → zh, else en). */ export type CopyKey = keyof typeof zh export function t(key: CopyKey): string { const lang = typeof navigator !== 'undefined' ? navigator.language : 'en' const dict = lang.toLowerCase().startsWith('zh') ? zh : en return dict[key] } /** Whether the browser language is Chinese (used for selectors). */ export function isZh(): boolean { return typeof navigator !== 'undefined' && navigator.language.toLowerCase().startsWith('zh') }