import { altKey, SETTINGS_LOCALE_EVENT, SETTINGS_PROTOCOL_VERSION, createSettingsTranslator, detectSystemSettingsLocale, resolveSettingsLocale, type SettingsLocaleEventV1, type SettingsTranslator, type SupportedSettingsLocale, type SystemSettingsLocaleOptions, type TranslationCatalogs, type TranslationParams, } from "pi-maestro-settings-core/v1"; export const COCKPIT_TUI_CATALOGS: TranslationCatalogs = { en: { "common.status.unknown": "unknown", "common.status.idle": "idle", "common.status.pending": "pending", "common.status.running": "running", "common.status.retrying": "retrying", "common.status.sleeping": "sleeping", "common.status.stalled": "stalled", "common.status.result-ready": "result ready", "common.status.done": "done", "common.status.completed": "completed", "common.status.failed": "failed", "common.status.terminated": "terminated", "common.status.stopping": "stopping", "common.status.killed": "killed", "common.status.settled": "settled", "common.status.selected": "selected", "common.total": "{count} total", "common.active": "{count} active", "common.running": "{count} running", "common.stopping": "{count} stopping", "common.pending": "{count} pending", "common.sleeping": "{count} sleeping", "common.stalled": "{count} stalled", "common.failed": "{count} failed", "common.terminated": "{count} terminated", "common.finished": "{count} finished", "common.done": "{count} done", "common.blocked": "{count} blocked", "common.agents": "{count} agents", "common.tools": "{count} tools", "common.members": "{count} members", "common.workers": "{count} workers", "common.goals": "{count} goals", "common.rows": "{count} rows", "common.more": "{count} more", "common.above": "{count} above", "common.value.on": "on", "common.value.off": "off", "common.value.yes": "yes", "common.value.no": "no", "common.value.hidden": "hidden", "common.value.visible": "visible", "common.value.list": "list", "common.value.compact": "compact", "common.value.auto": "auto", "common.value.comfortable": "comfortable", "common.value.classic": "classic", "common.value.zen": "zen", "common.value.picker": "picker…", "common.empty": "(empty)", "common.ruleBased": "(rule-based)", "common.customRef": "custom ref…", "session.listHint": `${altKey("R")} list`, "session.detailHint": `${altKey("R")} preview · ${altKey("E")} hide`, "session.previewHint": "PgUp/PgDn scroll output", "session.thinking": "thinking…", "session.working": "working…", "session.noActivity": "no activity for {duration}", "window.empty": "Windows · no peer sessions", "window.title": "Windows", "window.context": "context {percent}%", "window.currentCoordination": "Current session · monitor coordination", "window.noMessages": "No messages in this window thread.", "window.messages": "Messages", "message.receivedFrom": "Received from {sender}", "message.kind.message": "message", "message.kind.coordination": "coordination", "message.kind.request": "request", "message.kind.status": "status", "message.kind.supervision": "supervision", "window.source.monitor": "monitor", "window.mode.steer": "steer", "window.mode.followUp": "follow-up", "overlay.agents.title": "Agents", "overlay.agents.none": "none", "overlay.agents.noAgents": "No agents", "overlay.agents.noSelection": "No agent selected", "overlay.agents.aborted": "steer aborted: @{agent} is gone", "overlay.agents.help": "Esc close · ↑↓ agent · Home/End jump · PgUp/PgDn output · m target · i interrupt · s steer", "overlay.agents.targetAck": "input target @{agent}", "overlay.agents.composeHelp": "Enter send · Esc cancel", "overlay.agents.searchHint": "/ search", "overlay.agents.searchPrompt": "search:", "overlay.agents.noMatches": "No matching agents", "overlay.agents.searchHelp": "Esc clear · ↑↓ agent", "overlay.jobs.title": "Background jobs", "overlay.jobs.empty": "{mark} no background jobs{separator}use bash_bg action=start", "overlay.jobs.refreshing": "refreshing…", "overlay.jobs.help": "Esc close|Enter detail|{keys} job|Ctrl+R refresh", "overlay.jobs.detailHelp": "Esc back|{keys} job|Ctrl+R refresh", "overlay.jobs.field.duration": "Duration", "overlay.jobs.field.started": "Started", "overlay.jobs.field.updated": "Updated", "overlay.jobs.field.exit": "Exit", "overlay.jobs.field.output": "Output", "overlay.jobs.field.cwd": "CWD", "overlay.jobs.field.log": "Log", "overlay.jobs.command": "Command", "overlay.jobs.outputTail": "Output tail", "overlay.jobs.unknown": "unknown", "overlay.jobs.moreLines": "… +{count} more line(s)", "overlay.jobs.earlierLines": "… {count} earlier line(s) · full output at log path", "overlay.todo.title": "Todo", "overlay.todo.empty": "{mark} no todo tasks{separator}create one with the todo tool", "overlay.todo.noSelection": "No todo selected", "overlay.todo.help": "Esc close|Enter detail|{keys} todo", "overlay.todo.detailHelp": "Esc back|{keys} todo", "overlay.todo.field.status": "Status", "overlay.todo.field.assignee": "Assignee", "overlay.todo.field.createdBy": "Created by", "overlay.todo.field.blockedBy": "Blocked by", "overlay.todo.field.skills": "Skills", "overlay.todo.field.id": "ID", "bash.details": "{shortcut} details", "picker.theme.title": "theme", "picker.theme.empty": "no themes registered", "picker.theme.loadFailed": "{name} could not be loaded", "picker.theme.applyFailed": "could not apply {name}", "picker.theme.noPreview": "pi did not name its active theme — no preview", "picker.theme.move": "{keys} move", "picker.theme.apply": "Enter apply", "picker.theme.close": "Esc close", "picker.theme.preview": "{keys} preview", "picker.theme.save": "Enter save", "picker.theme.revert": "Esc revert", "picker.theme.settingsHint": "/settings pairs a light and a dark theme", "picker.model.title": "title model", "picker.model.empty": "no models registered", "picker.model.move": "{keys} move", "picker.model.save": "Enter save", "picker.model.cancel": "Esc cancel", "picker.model.source": "models come from /api-manager", "widget.agents.title": "Agents", "widget.agents.noun": "agents", "widget.todo.title": "Todo", "widget.todo.expand": "({shortcut} expand)", "widget.todo.collapse": "collapse", "widget.todo.expandAction": "expand", "widget.agent.lastFailed": "last failed", "widget.agent.expert": "◆ expert", "widget.agent.cli": "⌘ cli", "widget.agent.lastFailedMessage": "last failed: {message}", "widget.agent.cache": "cache {read}r/{write}w", "widget.agent.inputOutput": "in {input}{separator}out {output}", "widget.agent.tokens": "{count} tok", "sidebar.section.Workflow": "Workflow", "sidebar.section.Goal": "Goal", "sidebar.section.Tasks": "Tasks", "sidebar.section.Agents": "Agents", "sidebar.section.Jobs": "Jobs", "sidebar.section.Swarm": "Swarm", "zen.chain": "chain", "zen.blockedBy": "blocked by {ids}", "zen.detail.session": "session", "zen.detail.status": "status", "zen.detail.gates": "gates", "zen.detail.tokens": "tokens", "zen.detail.time": "time", "zen.detail.assignee": "assignee", "zen.detail.createdBy": "created by", "zen.detail.blockedBy": "blocked by", "zen.detail.skills": "skills", "zen.detail.run": "run", "zen.detail.chain": "chain", "zen.detail.task": "task", "zen.detail.model": "model", "zen.detail.error": "error", "zen.detail.tail": "output", "zen.detail.cwd": "cwd", "zen.detail.pid": "pid", "zen.detail.log": "log", "zen.detail.workers": "workers", "zen.detail.best": "best", "zen.browse.hint": "↑↓ move · Enter expand · Esc leave", "zen.sheet.breadcrumb.mission": "MISSION / DETAILS", "zen.sheet.breadcrumb.run": "WORK / RUN", "zen.sheet.breadcrumb.task": "WORK / TASK", "zen.sheet.breadcrumb.swarm": "ACTORS / SWARM", "zen.sheet.field.session": "session", "zen.sheet.field.goal": "goal", "zen.sheet.field.status": "status", "zen.sheet.field.gates": "gates", "zen.sheet.field.run": "run", "zen.sheet.field.chain": "chain", "zen.sheet.field.next": "next", "zen.sheet.field.iteration": "iteration", "zen.sheet.field.tokens": "tokens", "zen.sheet.field.time": "time", "zen.sheet.field.pause": "pause", "zen.sheet.field.task": "task", "zen.sheet.field.assignee": "assignee", "zen.sheet.field.createdBy": "created by", "zen.sheet.field.blockedBy": "blocked by", "zen.sheet.field.skills": "skills", "zen.sheet.field.updated": "updated", "zen.sheet.field.objective": "objective", "zen.sheet.field.workers": "workers", "zen.sheet.field.best": "best", "zen.sheet.help": "↑↓ scroll · PgUp/PgDn · Esc close", "zen.sheet.unavailable": "Zen detail is no longer available", "sidebar.next": "Next", "sidebar.iteration": "iteration {current}", "sidebar.iterationTotal": "iteration {current}/{total}", "sidebar.tokens": "{count} tokens", "sidebar.tokensBudget": "{used}/{budget} tokens", "sidebar.gates": "{passed}/{total} gates", "sidebar.currentGoal": "current {id}", "sidebar.best": "best {score}", "sidebar.deps": "{count} deps", "sidebar.viewing": "viewing", "sidebar.error": "error {message}", "sidebar.tool": "tool {name}", "sidebar.lastFailed": "last failed", "sidebar.lastFailedMessage": "last failed {message}", "sidebar.exit": "exit {code}", "sidebar.renderFailed": "render failed", "sidebar.title": "Cockpit sidebar", "sidebar.unavailable": "Cockpit sidebar unavailable", "sidebar.requiresTui": "Cockpit sidebar requires TUI mode", "ambient.working": "working", "ambient.failed": "{count} failed", "ambient.agents": "{count} agents", "legacy.label.enabled": "enabled", "legacy.label.staticMode": "static mode", "legacy.label.pinEditorBottom": "pin input bottom", "legacy.label.doubleEscapeClearInput": "double esc clear (reload)", "legacy.label.fullscreenInput": "fullscreen input (reload)", "legacy.label.copyOnSelect": "copy on select", "legacy.label.quietMode": "quiet (reload)", "legacy.label.quietSymbols": "quiet symbols", "legacy.label.thinkingFold": "thinking fold", "legacy.label.agentsMode": "agents", "legacy.label.todoMode": "todo", "legacy.label.todoExpanded": "todo expand", "legacy.label.stackStyle": "stack style", "legacy.label.hideNativeAgents": "hide native", "legacy.label.sidebarMode": "sidebar", "legacy.label.sidebarDensity": "sidebar density", "legacy.label.icons": "icons", "legacy.label.theme": "theme", "legacy.label.titleEnabled": "title", "legacy.label.titleSession": "title session", "legacy.label.titleCwd": "title cwd", "legacy.label.titleModel": "title model", "legacy.label.titleThinking": "title thinking", "legacy.label.titleGit": "title git", "legacy.label.titleMaestro": "title maestro", "legacy.label.titleGenerationModel": "title gen model", "legacy.piSettings": "(pi settings)", "legacy.saved": "✓ saved", "legacy.saving": "· saving…", "legacy.saveFailed": "✗ save failed — {message}", "legacy.sessionOnly": "cockpit rows apply for this session only", "legacy.storageHint": "theme & thinking are stored by pi", "legacy.themePairHint": "/settings pairs light+dark", "legacy.editHelp": "type · Enter save · Esc cancel", "legacy.help": "↑↓ move · Enter change · letter jumps · Esc close", "legacy.selectedEditHelp": " → Enter save · Esc cancel", "notice.closeOverlayAgents": "Close the open Cockpit overlay before opening Agents", "notice.noAgents": "No agents to display", "notice.closeOverlaySessions": "Close the open overlay before opening Sessions", "notice.noWindows": "No windows to display", "notice.noMonitorWindow": "No monitor window is selected.", "notice.monitorUnavailable": "Window monitor mode is unavailable in this session.", "notice.imagePeer": "Image input cannot be routed to a peer window; reattach it in #control or after leaving monitor mode.", "notice.peerDeliveryUnavailable": "Peer window delivery is unavailable.", "notice.peerMessageFailed": "Message to #{label} was not sent: {message}", "notice.deliveryRegistryUnavailable": "delivery registry unavailable", "notice.agentImage": "Image input cannot be routed to @{label}; attachments were not sent and must be reattached after switching to @main.", "notice.deliveryRejected": "delivery was rejected", "notice.agentRegistryUnavailable": "teammate delivery registry is unavailable", "notice.agentMessageFailed": "Message to @{label} was not sent: {message}", "notice.cockpitDisabled": "Cockpit is disabled", "notice.closeOverlayResize": "Close the open Cockpit overlay before resizing the sidebar", "notice.closeOverlayBrowse": "Close the open Cockpit overlay before browsing the sidebar", "notice.settingsRequiresTui": "Maestro settings require interactive TUI mode", "notice.sidebarNotVisible": "Cockpit sidebar is not visible", "notice.sidebarNothing": "Nothing to browse in the Cockpit sidebar", "notice.sidebarNotReady": "Cockpit sidebar is not ready to resize", "notice.sidebarTooNarrow": "Terminal is too narrow to resize the Cockpit sidebar", "notice.sessionDetailShown": "Agent session detail shown", "notice.sessionDetailHidden": "Agent session detail hidden", "notice.quietOn": "quiet mode on — tools compressed, thinking folded", "notice.quietOnPartial": "quiet mode on — tools compressed", "notice.quietOff": "quiet mode off — /reload to restore default tool rendering", "notice.quietOffReady": "quiet mode off", "notice.bottomPinnedDisabled": "Bottom-pinned input disabled: {message}", "notice.editorOwned": "Cockpit double-Escape clear / fullscreen input unavailable: another extension owns the custom editor", "notice.editorError": "Cockpit editor interaction error: {message}", "notice.fullscreenDisabled": "Cockpit fullscreen input disabled: {message}", "editor.historyBanner": "History {position}/{total}", "editor.historyUnavailable": "Input history unavailable: {message}", "notice.sidebarWidthSaveFailed": "Cockpit sidebar width kept for this session; save failed: {message}", "notice.sidebarUnavailable": "Cockpit sidebar unavailable: {message}", "notice.themeUnavailable": "theme \"{name}\" unavailable — {message}", "notice.themeSelected": "theme: {name}", "notice.notFound": "not found", "notice.unknownError": "unknown error", "notice.sidebarMode": "Cockpit sidebar: {mode}", "notice.sidebarDetails": "Cockpit sidebar: {mode} · {width} columns · {density}", "notice.sidebarModeSaveFailed": "Cockpit sidebar mode kept for this session; save failed: {message}", "notice.todoExpanded": "TODO expanded", "notice.todoCollapsed": "TODO collapsed", "notice.staticOn": "Cockpit static mode on — live updates reduced", "notice.staticOff": "Cockpit static mode off", "notice.staticSaveFailed": "Cockpit static mode kept for this session; save failed", "notice.usageDisabled": "Usage bars are disabled in Cockpit settings", "supervision.idle": "idle (no events)", "supervision.counts": " interventions: {interventions} · notifications: {notifications} · verdicts: {verdicts}", "supervision.help": " /supervision events — list recent events", "supervision.none": "No supervision events observed yet.", "supervision.recent": "SUPERVISION recent {count}", "thinking.thoughts": "thoughts", "thinking.thinking": "thinking", "selection.copied": "Copied {chars} chars", "selection.copiedLines": "Copied {chars} chars · {lines} lines", "selection.copyFailed": "Copy failed: {message}", }, "zh-CN": { "common.status.unknown": "未知", "common.status.idle": "空闲", "common.status.pending": "等待中", "common.status.running": "运行中", "common.status.retrying": "重试中", "common.status.sleeping": "休眠中", "common.status.stalled": "已停滞", "common.status.result-ready": "结果已就绪", "common.status.done": "已完成", "common.status.completed": "已完成", "common.status.failed": "失败", "common.status.terminated": "已终止", "common.status.stopping": "停止中", "common.status.killed": "已结束", "common.status.settled": "已结束", "common.status.selected": "已选择", "common.total": "共 {count} 项", "common.active": "{count} 项活跃", "common.running": "{count} 项运行中", "common.stopping": "{count} 项停止中", "common.pending": "{count} 项等待中", "common.sleeping": "{count} 项休眠中", "common.stalled": "{count} 项停滞", "common.failed": "{count} 项失败", "common.terminated": "{count} 项已终止", "common.finished": "{count} 项已结束", "common.done": "{count} 项已完成", "common.blocked": "{count} 项受阻", "common.agents": "{count} 个 Agent", "common.tools": "{count} 次工具调用", "common.members": "{count} 名成员", "common.workers": "{count} 个 Worker", "common.goals": "{count} 个目标", "common.rows": "{count} 行", "common.more": "还有 {count} 项", "common.above": "上方 {count} 项", "common.value.on": "开启", "common.value.off": "关闭", "common.value.yes": "是", "common.value.no": "否", "common.value.hidden": "隐藏", "common.value.visible": "显示", "common.value.list": "列表", "common.value.compact": "紧凑", "common.value.auto": "自动", "common.value.comfortable": "舒适", "common.value.classic": "经典", "common.value.zen": "Zen", "common.value.picker": "选择器…", "common.empty": "(空)", "common.ruleBased": "(规则生成)", "common.customRef": "自定义引用…", "session.listHint": `${altKey("R")} 列表`, "session.detailHint": `${altKey("R")} 预览 · ${altKey("E")} 隐藏`, "session.previewHint": "PgUp/PgDn 滚动输出", "session.thinking": "思考中…", "session.working": "工作中…", "session.noActivity": "已 {duration} 无活动", "window.empty": "窗口 · 没有对等会话", "window.title": "窗口", "window.context": "上下文 {percent}%", "window.currentCoordination": "当前会话 · Monitor 协调", "window.noMessages": "此窗口线程中没有消息。", "window.messages": "消息", "message.receivedFrom": "收到来自 {sender} 的消息", "message.kind.message": "消息", "message.kind.coordination": "协调", "message.kind.request": "请求", "message.kind.status": "状态", "message.kind.supervision": "监督", "window.source.monitor": "监控", "window.mode.steer": "引导", "window.mode.followUp": "跟进", "overlay.agents.title": "Agent", "overlay.agents.none": "无", "overlay.agents.noAgents": "没有 Agent", "overlay.agents.noSelection": "未选择 Agent", "overlay.agents.aborted": "引导已取消:@{agent} 已离开", "overlay.agents.help": "Esc 关闭 · ↑↓ Agent · Home/End 跳转 · PgUp/PgDn 输出 · m 设为目标 · i 打断 · s 引导", "overlay.agents.targetAck": "输入目标 @{agent}", "overlay.agents.composeHelp": "Enter 发送 · Esc 取消", "overlay.agents.searchHint": "/ 搜索", "overlay.agents.searchPrompt": "搜索:", "overlay.agents.noMatches": "没有匹配的 Agent", "overlay.agents.searchHelp": "Esc 清除 · ↑↓ Agent", "overlay.jobs.title": "后台任务", "overlay.jobs.empty": "{mark} 没有后台任务{separator}使用 bash_bg action=start", "overlay.jobs.refreshing": "刷新中…", "overlay.jobs.help": "Esc 关闭|Enter 详情|{keys} 任务|Ctrl+R 刷新", "overlay.jobs.detailHelp": "Esc 返回|{keys} 任务|Ctrl+R 刷新", "overlay.jobs.field.duration": "时长", "overlay.jobs.field.started": "开始时间", "overlay.jobs.field.updated": "更新时间", "overlay.jobs.field.exit": "退出码", "overlay.jobs.field.output": "输出量", "overlay.jobs.field.cwd": "工作目录", "overlay.jobs.field.log": "日志", "overlay.jobs.command": "命令", "overlay.jobs.outputTail": "输出末尾", "overlay.jobs.unknown": "未知", "overlay.jobs.moreLines": "… 还有 {count} 行", "overlay.jobs.earlierLines": "… 省略前面 {count} 行 · 完整输出见日志路径", "overlay.todo.title": "Todo", "overlay.todo.empty": "{mark} 没有 Todo 任务{separator}使用 todo 工具创建", "overlay.todo.noSelection": "未选择 Todo", "overlay.todo.help": "Esc 关闭|Enter 详情|{keys} 任务", "overlay.todo.detailHelp": "Esc 返回|{keys} 任务", "overlay.todo.field.status": "状态", "overlay.todo.field.assignee": "负责人", "overlay.todo.field.createdBy": "创建者", "overlay.todo.field.blockedBy": "阻塞于", "overlay.todo.field.skills": "技能", "overlay.todo.field.id": "ID", "bash.details": "{shortcut} 详情", "picker.theme.title": "主题", "picker.theme.empty": "没有已注册的主题", "picker.theme.loadFailed": "无法加载 {name}", "picker.theme.applyFailed": "无法应用 {name}", "picker.theme.noPreview": "pi 未提供当前主题名称,无法预览", "picker.theme.move": "{keys} 移动", "picker.theme.apply": "Enter 应用", "picker.theme.close": "Esc 关闭", "picker.theme.preview": "{keys} 预览", "picker.theme.save": "Enter 保存", "picker.theme.revert": "Esc 还原", "picker.theme.settingsHint": "/settings 可配对浅色和深色主题", "picker.model.title": "标题模型", "picker.model.empty": "没有已注册的模型", "picker.model.move": "{keys} 移动", "picker.model.save": "Enter 保存", "picker.model.cancel": "Esc 取消", "picker.model.source": "模型来自 /api-manager", "widget.agents.title": "Agent", "widget.agents.noun": "Agent", "widget.todo.title": "Todo", "widget.todo.expand": "({shortcut} 展开)", "widget.todo.collapse": "收起", "widget.todo.expandAction": "展开", "widget.agent.lastFailed": "上次失败", "widget.agent.expert": "◆ expert", "widget.agent.cli": "⌘ cli", "widget.agent.lastFailedMessage": "上次失败:{message}", "widget.agent.cache": "缓存 {read}读/{write}写", "widget.agent.inputOutput": "入 {input}{separator}出 {output}", "widget.agent.tokens": "{count} 词元", "sidebar.section.Workflow": "工作流", "sidebar.section.Goal": "目标", "sidebar.section.Tasks": "Tasks", "sidebar.section.Agents": "Agent", "sidebar.section.Jobs": "后台任务", "sidebar.section.Swarm": "群组", "zen.chain": "链", "zen.blockedBy": "受阻于 {ids}", "zen.detail.session": "会话", "zen.detail.status": "状态", "zen.detail.gates": "门禁", "zen.detail.tokens": "词元", "zen.detail.time": "耗时", "zen.detail.assignee": "负责人", "zen.detail.createdBy": "创建者", "zen.detail.blockedBy": "受阻于", "zen.detail.skills": "技能", "zen.detail.run": "运行", "zen.detail.chain": "链", "zen.detail.task": "任务", "zen.detail.model": "模型", "zen.detail.error": "错误", "zen.detail.tail": "输出", "zen.detail.cwd": "目录", "zen.detail.pid": "进程", "zen.detail.log": "日志", "zen.detail.workers": "成员", "zen.detail.best": "最佳", "zen.browse.hint": "↑↓ 移动 · Enter 展开 · Esc 退出", "zen.sheet.breadcrumb.mission": "使命 / 详情", "zen.sheet.breadcrumb.run": "工作 / 运行", "zen.sheet.breadcrumb.task": "工作 / 任务", "zen.sheet.breadcrumb.swarm": "参与者 / 群组", "zen.sheet.field.session": "会话", "zen.sheet.field.goal": "目标", "zen.sheet.field.status": "状态", "zen.sheet.field.gates": "门禁", "zen.sheet.field.run": "运行", "zen.sheet.field.chain": "链", "zen.sheet.field.next": "下一步", "zen.sheet.field.iteration": "轮次", "zen.sheet.field.tokens": "词元", "zen.sheet.field.time": "耗时", "zen.sheet.field.pause": "暂停", "zen.sheet.field.task": "任务", "zen.sheet.field.assignee": "负责人", "zen.sheet.field.createdBy": "创建者", "zen.sheet.field.blockedBy": "受阻于", "zen.sheet.field.skills": "技能", "zen.sheet.field.updated": "更新时间", "zen.sheet.field.objective": "目标", "zen.sheet.field.workers": "成员", "zen.sheet.field.best": "最佳", "zen.sheet.help": "↑↓ 滚动 · PgUp/PgDn · Esc 关闭", "zen.sheet.unavailable": "Zen 详情已不可用", "sidebar.next": "下一步", "sidebar.iteration": "第 {current} 轮", "sidebar.iterationTotal": "第 {current}/{total} 轮", "sidebar.tokens": "{count} 词元", "sidebar.tokensBudget": "{used}/{budget} 词元", "sidebar.gates": "门禁 {passed}/{total}", "sidebar.currentGoal": "当前 {id}", "sidebar.best": "最佳 {score}", "sidebar.deps": "{count} 个依赖", "sidebar.viewing": "正在查看", "sidebar.error": "错误 {message}", "sidebar.tool": "工具 {name}", "sidebar.lastFailed": "上次失败", "sidebar.lastFailedMessage": "上次失败 {message}", "sidebar.exit": "退出码 {code}", "sidebar.renderFailed": "渲染失败", "sidebar.title": "Cockpit 侧边栏", "sidebar.unavailable": "Cockpit 侧边栏不可用", "sidebar.requiresTui": "Cockpit 侧边栏需要 TUI 模式", "ambient.working": "工作中", "ambient.failed": "{count} 项失败", "ambient.agents": "{count} 个 Agent", "legacy.label.enabled": "启用", "legacy.label.staticMode": "静态模式", "legacy.label.pinEditorBottom": "输入固定到底部", "legacy.label.doubleEscapeClearInput": "双击 Esc 清空(需重载)", "legacy.label.fullscreenInput": "全屏输入(需重载)", "legacy.label.copyOnSelect": "选择即复制", "legacy.label.quietMode": "安静模式(需重载)", "legacy.label.quietSymbols": "安静模式符号", "legacy.label.thinkingFold": "折叠思考", "legacy.label.agentsMode": "Agent", "legacy.label.todoMode": "todo", "legacy.label.todoExpanded": "todo 展开", "legacy.label.stackStyle": "栈投影", "legacy.label.hideNativeAgents": "隐藏原生 Agent", "legacy.label.sidebarMode": "侧边栏", "legacy.label.sidebarDensity": "侧边栏密度", "legacy.label.icons": "图标", "legacy.label.theme": "主题", "legacy.label.titleEnabled": "终端标题", "legacy.label.titleSession": "标题显示会话", "legacy.label.titleCwd": "标题显示目录", "legacy.label.titleModel": "标题显示模型", "legacy.label.titleThinking": "标题显示思考级别", "legacy.label.titleGit": "标题显示 Git", "legacy.label.titleMaestro": "标题显示 Maestro", "legacy.label.titleGenerationModel": "标题生成模型", "legacy.piSettings": "(由 pi 设置)", "legacy.saved": "✓ 已保存", "legacy.saving": "· 保存中…", "legacy.saveFailed": "✗ 保存失败 — {message}", "legacy.sessionOnly": "Cockpit 配置仅在本会话生效", "legacy.storageHint": "主题和思考折叠由 pi 保存", "legacy.themePairHint": "/settings 可配对浅色和深色主题", "legacy.editHelp": "输入 · Enter 保存 · Esc 取消", "legacy.help": "↑↓ 移动 · Enter 修改 · 字母跳转 · Esc 关闭", "legacy.selectedEditHelp": " → Enter 保存 · Esc 取消", "notice.closeOverlayAgents": "请先关闭当前 Cockpit 浮层,再打开 Agent", "notice.noAgents": "没有可显示的 Agent", "notice.closeOverlaySessions": "请先关闭当前浮层,再打开会话列表", "notice.noWindows": "没有可显示的窗口", "notice.noMonitorWindow": "未选择 Monitor 窗口。", "notice.monitorUnavailable": "当前会话不支持窗口监控模式。", "notice.imagePeer": "无法将图片路由到对等窗口;请在 #control 中或离开 Monitor 模式后重新附加。", "notice.peerDeliveryUnavailable": "对等窗口消息发送不可用。", "notice.peerMessageFailed": "发送到 #{label} 的消息失败:{message}", "notice.deliveryRegistryUnavailable": "发送注册表不可用", "notice.agentImage": "无法将图片路由到 @{label};附件未发送,请切换到 @main 后重新附加。", "notice.deliveryRejected": "消息发送被拒绝", "notice.agentRegistryUnavailable": "teammate 消息发送注册表不可用", "notice.agentMessageFailed": "发送到 @{label} 的消息失败:{message}", "notice.cockpitDisabled": "Cockpit 已禁用", "notice.closeOverlayResize": "请先关闭当前 Cockpit 浮层,再调整侧边栏", "notice.closeOverlayBrowse": "请先关闭当前 Cockpit 浮层,再浏览侧边栏", "notice.settingsRequiresTui": "Maestro 设置需要交互式 TUI 模式", "notice.sidebarNotVisible": "Cockpit 侧边栏当前不可见", "notice.sidebarNothing": "Cockpit 侧边栏中没有可浏览内容", "notice.sidebarNotReady": "Cockpit 侧边栏尚未准备好调整大小", "notice.sidebarTooNarrow": "终端过窄,无法调整 Cockpit 侧边栏", "notice.sessionDetailShown": "已显示 Agent 会话详情", "notice.sessionDetailHidden": "已隐藏 Agent 会话详情", "notice.quietOn": "安静模式已开启 — 工具输出已压缩,思考已折叠", "notice.quietOnPartial": "安静模式已开启 — 工具输出已压缩;无法折叠思考", "notice.quietOff": "安静模式已关闭 — 执行 /reload 可恢复默认工具渲染", "notice.quietOffReady": "安静模式已关闭", "notice.bottomPinnedDisabled": "底部固定输入已禁用:{message}", "notice.editorOwned": "Cockpit 双击 Esc 清空/全屏输入不可用:自定义编辑器由其他扩展占用", "notice.editorError": "Cockpit 编辑器交互错误:{message}", "notice.fullscreenDisabled": "Cockpit 全屏输入已禁用:{message}", "editor.historyBanner": "历史 {position}/{total}", "editor.historyUnavailable": "输入历史不可用:{message}", "notice.sidebarWidthSaveFailed": "侧边栏宽度仅在本会话保留;保存失败:{message}", "notice.sidebarUnavailable": "Cockpit 侧边栏不可用:{message}", "notice.themeUnavailable": "主题 \"{name}\" 不可用 — {message}", "notice.themeSelected": "主题:{name}", "notice.notFound": "未找到", "notice.unknownError": "未知错误", "notice.sidebarMode": "Cockpit 侧边栏:{mode}", "notice.sidebarDetails": "Cockpit 侧边栏:{mode} · {width} 列 · {density}", "notice.sidebarModeSaveFailed": "侧边栏模式仅在本会话保留;保存失败:{message}", "notice.todoExpanded": "Todo 已展开", "notice.todoCollapsed": "Todo 已收起", "notice.staticOn": "Cockpit 静态模式已开启 — 实时更新已减少", "notice.staticOff": "Cockpit 静态模式已关闭", "notice.staticSaveFailed": "Cockpit 静态模式仅在本会话保留;保存失败", "notice.usageDisabled": "Cockpit 设置中已禁用用量条", "supervision.idle": "空闲(没有事件)", "supervision.counts": " 干预:{interventions} · 通知:{notifications} · 结论:{verdicts}", "supervision.help": " /supervision events — 列出最近事件", "supervision.none": "尚未观察到监督事件。", "supervision.recent": "SUPERVISION 最近 {count} 项", "thinking.thoughts": "思考", "thinking.thinking": "思考中", "selection.copied": "已复制 {chars} 个字符", "selection.copiedLines": "已复制 {chars} 个字符 · {lines} 行", "selection.copyFailed": "复制失败:{message}", }, }; const STATUS_KEYS: Readonly> = { unknown: "common.status.unknown", idle: "common.status.idle", pending: "common.status.pending", running: "common.status.running", retrying: "common.status.retrying", sleeping: "common.status.sleeping", stalled: "common.status.stalled", "result-ready": "common.status.result-ready", done: "common.status.done", completed: "common.status.completed", failed: "common.status.failed", terminated: "common.status.terminated", stopping: "common.status.stopping", killed: "common.status.killed", settled: "common.status.settled", selected: "common.status.selected", }; export interface CockpitTuiLocaleOptions extends SystemSettingsLocaleOptions { locale?: string | null; detectSystemLocale?: (options?: SystemSettingsLocaleOptions) => SupportedSettingsLocale; } export interface CockpitLocaleEventSource { on(event: string, handler: (payload: unknown) => void): void | (() => void); } export class CockpitTuiLocale { private readonly translator: SettingsTranslator; private readonly listeners = new Set<(locale: SupportedSettingsLocale) => void>(); constructor(options: CockpitTuiLocaleOptions = {}) { const systemOptions: SystemSettingsLocaleOptions = { ...(options.environment === undefined ? {} : { environment: options.environment }), ...(options.resolvedLocale === undefined ? {} : { resolvedLocale: options.resolvedLocale }), }; const locale = options.locale === undefined || options.locale?.trim().toLowerCase() === "auto" ? (options.detectSystemLocale ?? detectSystemSettingsLocale)(systemOptions) : resolveSettingsLocale(options.locale, systemOptions); this.translator = createSettingsTranslator({ locale, catalogs: COCKPIT_TUI_CATALOGS }); } get locale(): SupportedSettingsLocale { return this.translator.locale; } setLocale(locale: string | null | undefined): SupportedSettingsLocale { const previous = this.translator.locale; const next = this.translator.setLocale(locale); if (next === previous) return next; for (const listener of [...this.listeners]) { try { listener(next); } catch { /* locale observers must not break the caller */ } } return next; } t(key: string, params?: TranslationParams): string { return this.translator.t(key, params); } subscribe(listener: (locale: SupportedSettingsLocale) => void): () => void { this.listeners.add(listener); return () => this.listeners.delete(listener); } applyEvent(payload: unknown): boolean { if (!isSettingsLocaleEvent(payload)) return false; this.setLocale(payload.locale); return true; } } function isSettingsLocaleEvent(payload: unknown): payload is SettingsLocaleEventV1 { if (!payload || typeof payload !== "object" || Array.isArray(payload)) return false; const event = payload as Partial; return event.version === SETTINGS_PROTOCOL_VERSION && (event.locale === "en" || event.locale === "zh-CN") && typeof event.generation === "string" && event.generation.trim().length > 0; } export const cockpitTuiLocale = new CockpitTuiLocale(); export function tuiT(key: string, params?: TranslationParams): string { return cockpitTuiLocale.t(key, params); } export function tuiStatus(status: string): string { const normalized = status.trim().toLowerCase().replaceAll("_", "-").replaceAll(" ", "-"); const key = STATUS_KEYS[normalized]; return key ? tuiT(key) : status; } export function bindCockpitTuiLocale( events: CockpitLocaleEventSource, runtime: CockpitTuiLocale = cockpitTuiLocale, ): () => void { const result = events.on(SETTINGS_LOCALE_EVENT, (payload) => runtime.applyEvent(payload)); return typeof result === "function" ? result : () => {}; }