export type Locale = 'zh' | 'en'

const messages = {
  zh: {
    appProjectSpace: '项目空间',
    appProjectNotSelected: '未选择项目',
    appGlobalHome: '全局首页',
    appReturnHome: '返回首页',
    appExpandSidebar: '展开侧栏',
    appCollapseSidebar: '收起侧栏',
    appProfile: '个人中心',
    appTeamManagement: '团队管理',
    appSettings: '设置',
    appSwitchLightTheme: '切换为亮色主题',
    appSwitchDarkTheme: '切换为暗色主题',
    appCreateProject: '新建项目',
    appContextLinks: 'Context Links',
    homeTitle: '{count} 个项目正在运行',
    homeSubtitle: '从愿景到证据的全链路：Rumbling 守住你的意图、真相与方向——不论你在"还不知道要做什么"还是"证据证明做对了"阶段。',
    homeMyProjects: '我的项目',
    homeTodayFocus: '需要你决策',
    homeNoPriorityBlockers: '当前没有需要人拍板的事项。',
    homeRecentEvents: '最新真相信号',
    homeCreateProject: '新建项目',
    homeCreateProjectHint: '支持空白项目或从 GitHub / GitLab 快速导入。',
    homeNoProjectsYet: '还没有项目，创建第一个项目开始。',
    homeIntentDiff: '意图 vs 真相',
    homeIntentDiffHint: '当前意图与代码现实之间的差距',
    homeAttentionInbox: '注意力收件箱',
    homeAttentionInboxHint: '只装必须由你拍板的事，其余全部由 agent 处理',
    homeAgentRuns: 'Agent 运行流',
    homeNoAttentionItems: '太好了，当前没有需要你做决策的事项。',
    settingsTitle: '设置',
    settingsIntro: '先提供产品骨架层关键设置：主题、默认首页、通知偏好。团队成员与角色请在团队管理中维护。',
    settingsTheme: '主题',
    settingsLanguage: '语言',
    settingsDefaultHome: '默认进入页面',
    settingsGlobalHome: '全局首页',
    settingsRecentProject: '最近项目',
    settingsNotifications: '通知',
    settingsNotificationsHint: '接收风险和状态变化提醒',
    settingsMembersAndPermissions: '成员与权限',
    settingsCurrentRole: '当前平台角色',
    settingsMemberStatus: '成员状态',
    settingsGoTeam: '前往团队管理',
    projectCreateTitle: '新建项目',
    projectCreateIntro: '支持空白项目创建，或从 GitHub / GitLab 仓库快速导入。',
    projectCreateNoPermission: '当前账号无新建项目权限，请联系 Owner/Admin。',
    projectCreateStepSource: '来源',
    projectCreateStepRepo: '仓库',
    projectCreateStepBasics: '基础信息',
    projectCreateStepImport: '导入选项',
    projectCreateSourceScratch: '空白项目',
    projectCreateSourceScratchHint: '创建后手动配置代码与上下文。',
    projectCreateSourceGithubHint: '使用 GitHub 仓库预填项目信息。',
    projectCreateSourceGitlabHint: '使用 GitLab 仓库预填项目信息。',
    projectCreateScratchSkipRepo: '空白项目无需选择仓库，点击下一步继续。',
    projectCreateSelectConnection: '选择 Git 连接',
    projectCreateSearchRepo: '搜索仓库',
    projectCreateLoadingRepos: '仓库加载中...',
    projectCreateNoRepos: '暂无可用仓库',
    projectCreateBranch: '分支（默认 main）',
    projectCreateProjectName: '项目名称',
    projectCreateProjectDescription: '项目描述（可选）',
    projectCreateImportReadme: '导入 README 作为 Wiki 初始文档',
    projectCreateImportIssues: '导入 Issues 作为 Specs 占位',
    projectCreateSubscribeWebhooks: '订阅 CI / PR / Issue 事件',
    projectCreateDefaultAiIntegration: '默认 AI 接入（可选）',
    projectCreateNoDefaultAiIntegration: '不设置默认 AI 接入',
    projectCreateCancel: '取消',
    projectCreatePrev: '上一步',
    projectCreateNext: '下一步',
    projectCreateSubmit: '创建项目',
    projectCreateSubmitting: '创建中...',
    projectPulseContext: 'Pulse',
    projectPlanContext: '进度投影',
    projectKnowledgeContext: 'Knowledge',
    projectArchitectureContext: 'Memory',
    projectSpecsContext: 'Specs',
    intentLayerAspiration: 'Aspiration',
    intentLayerAspirationHint: '愿景/假设级——不能直接派 Agent Run',
    intentLayerExecutable: 'Executable',
    intentLayerExecutableHint: '可执行级——可派 Agent Run',
    intentFalsifiableBy: '什么 Reality 会证伪它',
    projectOverview: 'Project Overview',
    projectUpdated: '更新于',
    projectAgents: '个 agents',
    projectHealth: '健康分',
    projectRisks: '个风险',
    projectCurrentContext: '当前上下文：',
    projectIntentMap: 'Coordinates',
    projectAgentRuns: 'Agent Runs',
    archTabOverview: '结构',
    archTabDecisions: '决策',
    archTabDrift: '偏差',
    archTabKnowledge: '知识',
    archTabOverviewHint: '服务、模块、技术栈与依赖关系——agent 下次运行的记忆基础',
    archTabDecisionsHint: 'ADR：每一条决策都是 agent 行动的边界',
    archTabDriftHint: '意图与现实之间的差距，等待你裁决',
    archTabKnowledgeHint: '运行手册、指南与 API 记忆，供后续 agent 复用',
    memoryTitle: 'Memory · Agent 长期记忆',
    memorySubtitle: '这里存储的内容是 agent 在下一次运行时会读取的上下文。保持它准确，agent 才能做出正确的判断。',
    archOverviewStack: '技术栈',
    archOverviewComponents: '组件',
    archOverviewDependencies: '依赖关系',
    archOverviewAutoDetected: '自动识别',
    archOverviewManual: '手工登记',
    archOverviewEmpty: '暂无架构组件数据',
    archKindFrontend: '前端',
    archKindService: '服务',
    archKindWorker: '异步任务',
    archKindDatastore: '数据存储',
    archKindExternal: '外部依赖',
    archKindModule: '模块',
    archDriftTotal: '未处理偏差',
    archDriftEmpty: '暂未检测到架构偏差',
    archDriftAction: '建议操作',
    archDriftSource: '来源',
    archDriftSeverityHigh: '高',
    archDriftSeverityMedium: '中',
    archDriftSeverityLow: '低',
    archDriftKindAdr: 'ADR 偏差',
    archDriftKindDependency: '依赖偏差',
    archDriftKindStack: '技术栈偏差',
    archDriftKindInterface: '接口偏差',
    archDriftUpdateDesign: '更新设计',
    archDriftFixCode: '提任务修代码',
    archDriftIgnore: '标记忽略',
    archDecisionCreateTitle: '新建 ADR',
    archDecisionCreateHint: '沉淀架构决策，连接 Specs 与执行',
    archDecisionFieldTitle: '标题',
    archDecisionFieldContext: '背景 Context',
    archDecisionFieldDecision: '决策 Decision',
    archDecisionFieldConsequences: '影响 Consequences',
    archDecisionFieldReqs: '关联 Specs（逗号分隔）',
    archDecisionCancel: '取消',
    archDecisionSubmit: '创建 ADR',
    archOverviewDetailSummary: '组件说明',
    archOverviewDetailDependenciesOut: '出站依赖',
    archOverviewDetailDependenciesIn: '入站依赖',
    archOverviewDetailNone: '暂无',
    settingsLayoutTitle: '布局与外观',
    settingsDarkMode: '深色模式',
    settingsThemeHint: '切换界面主题',
    settingsLanguageHint: '界面显示语言',
    settingsDefaultHomeHint: '打开应用时显示的内容',
    settingsLastProject: '上次项目',
    settingsEditor: '文件查看器',
    settingsEditorHint: '点击源码链接时使用的编辑器',
    settingsSystemConfig: '系统配置',
    appSearch: '搜索',
    wikiSearchPlaceholder: '按下 Command + K 搜索文档和内容…',
    wikiSearchNoResults: '未找到匹配内容',
    wikiSearchHint: '输入关键词搜索所有文档',
    appHome: '首页',
    appLightMode: '浅色模式',
    appDarkMode: '深色模式',
    appImportProject: '导入项目',
    appSwitchProject: '切换项目',
    appRemoveProject: '移除项目',
    appRemoveProjectConfirm: '确定要移除「{name}」吗？项目配置和元数据将被永久删除，此操作不可撤销。',
    appRemoveProjectRunning: '该项目正在运行中，移除前将自动关闭并中断所有连接。',
    appCancel: '取消',
    appConfirmRemove: '确认移除',
    appRemoving: '移除中…',
    appNeedProject: '需先选择项目',
    wikiDocument: '文档',
    wikiPlan: '规划',
    welcomeImportHint: '导入项目开始使用',
    welcomeConnectHint: '连接你的代码仓库，开始分析与协作',
    commonSave: '保存',
    commonSaving: '保存中...',
    commonSaved: '已保存',
    commonAdd: '添加',
    commonCancel: '取消',
    commonDelete: '删除',
    commonDeleting: '删除中…',
    commonConfirmDelete: '确认删除',
    commonClose: '关闭面板',
    commonFlipPanel: '切换面板位置 (左/右)',
    commonSearch: '搜索',
    commonLoading: '加载中...',
    commonCustom: '自定义',
    panelSearch: '搜索',
    panelSettings: '设置',
    panelProjects: '项目',
    titlebarSessions: '会话',
    titlebarNotifications: '通知',
    projectLoadingTitle: '加载项目…',
    projectLoadingDesc: '正在从服务器获取项目信息',
    projectUnknown: '未知项目',
    projectNotFound: '未找到该项目，可能已被删除或 ID 不正确。',
    projectNotInList: '列表中暂无该项目，请返回首页同步。',
    projectNavConfig: '项目配置',
    projectSearchPlaceholder: '搜索项目…',
    projectNoMatch: '无匹配项目',
    projectNone: '暂无项目',
    projectDeleteTitle: '删除项目「{name}」',
    projectDeleteIrreversible: '此操作不可撤销。',
    projectDeleteGitWarning: 'Git 工作目录中的克隆代码也将被清理。',
    settingsProjectTitle: '项目设置',
    settingsProjectBack: '返回项目',
    settingsTabBasics: '基础信息',
    settingsTabCollaboration: '协作',
    settingsTabNotifications: '通知',
    settingsTabCompliance: '合规',
    settingsLimitsTitle: '运行限制',
    settingsMaxAgents: '单项目最大 Agent',
    settingsMaxAgentsDesc: '每个项目允许的最大并发 Agent 数',
    settingsAgentTimeout: 'Agent 超时 (秒)',
    settingsAgentTimeoutDesc: 'Agent 执行超时时间',
    settingsAdvancedTitle: '高级',
    settingsShowSessionsTab: '显示 Sessions 面板',
    settingsShowSessionsTabDesc: '启用后在导航栏显示 Sessions 调试面板',
    settingsAllowProjectOverride: '允许项目覆盖连接参数',
    settingsAllowProjectOverrideDesc: '项目可自定义 ACP 连接配置',
    settingsOpenConfigFile: '打开配置文件',
    settingsOpenConfigFileDesc: '在系统编辑器中打开 JSON 配置文件，保存后自动同步',
    settingsAcpTitle: 'ACP',
    settingsAcpRefresh: '刷新检测',
    settingsAcpRefreshing: '检测中',
    settingsAcpEmpty: '未发现可用的 ACP 端点，点击刷新重试。',
    settingsAcpAvailable: '可用',
    settingsAcpInstalled: '已安装',
    settingsAcpMissing: '未安装',
    settingsAcpFailed: '失败',
    settingsMcpTitle: 'MCP 配置',
    settingsMcpComingSoon: '即将推出',
    settingsMcpDesc: 'MCP (Model Context Protocol) 服务器配置将在后续版本中支持，届时可在此管理外部工具连接。',
    llmConfigError: 'LLM 配置有误',
    llmConfigErrorGoSettings: '前往配置',
    llmNoProviderConfigured: '未配置可用的 LLM Provider，请在设置中配置。',
    llmProviderAdd: '添加',
    llmProviderCustom: '自定义',
    llmProviderEmpty: '暂无已配置的 Provider，点击添加开始配置。',
    llmProviderSaveFailed: '保存失败',
    llmProviderSaveSuccess: '✓ 连接成功，已保存',
    llmProviderConnectFailed: '连接失败，未保存',
    llmProviderDiscoverCount: '发现 {count} 个模型',
    llmProviderDiscoverFailed: '发现失败',
    llmProviderRequestFailed: '请求失败',
    llmCardDefault: '默认',
    llmCardSetDefault: '设为默认',
    llmCardSave: '保存 Provider',
    llmCardValidate: '验证连接',
    llmCardDelete: '删除',
    llmCardDiscover: '发现',
    llmCardModel: '模型',
    llmCardApiKeyPlaceholder: '输入 API Key',
    basicsProjectName: '项目名称',
    basicsEnvironment: '环境',
    basicsDescription: '描述',
    basicsDescriptionPlaceholder: '项目描述...',
    basicsVisibility: '可见性',
    basicsOwner: '所有者',
    basicsMemberId: '成员 ID',
    basicsTags: '标签',
    basicsAddTagPlaceholder: '添加标签...',
    collabAgentPermissions: 'Agent 权限',
    collabAllowDirectCommit: '允许 Agent 直接提交代码',
    collabReviewPolicy: 'Review 策略',
    collabMinApprovals: '最少审批数',
    collabRequireQa: '需要 QA 审批',
    collabRequireOwner: '需要 Owner 审批',
    collabBlockOnCi: 'CI 失败时阻止合并',
    notifChannel: '通知渠道',
    notifChannelNone: '关闭',
    notifMinSeverity: '最低严重级别',
    notifQuietHours: '静默时段',
    notifQuietHoursPlaceholder: '例: 22:00-08:00',
    notifRecipients: '接收人',
    notifAddRecipientPlaceholder: '添加接收人...',
    complianceRetentionDays: '数据保留天数',
    complianceAuditLog: '启用审计日志',
    complianceDataExport: '允许数据导出',
    compliancePiiMasking: 'PII 脱敏',
    providerAcpOverride: 'ACP Provider 覆盖',
    providerInheritGlobal: '继承全局 ({id})',
    providerUseDefault: '使用默认',
    providerConnectionOverride: '连接覆盖',
    providerInheritGlobalPlaceholder: '继承全局',
    providerLimitsOverride: 'Limits 覆盖',
    providerMaxAgents: '最大 Agent 数',
    providerTimeout: '超时 (秒)',
    wikiEmpty: '暂无 Wiki',
    wikiEmptyDesc: '该项目还没有生成 Codebase Design Wiki。',
    wikiEmptyDescLine2: '点击下方按钮，AI 将分析代码库并生成结构化设计文档。',
    wikiGenerating: '生成中…',
    wikiGenerate: '生成 Wiki',
    wikiFailedTitle: 'Wiki 生成失败',
    wikiFailedDesc: '上次生成任务未能完成，可能是代码分析或 LLM 调用出错。',
    wikiRetrying: '重新生成中…',
    wikiRetry: '重新生成',
    wikiPlans: '规划',
    wikiDocuments: '文档',
    wikiSelectDocument: '从左侧选择文档',
    wikiReinitConfirmTitle: '确认重新初始化',
    wikiReinitConfirmDesc: '此操作将删除当前项目的所有 Wiki 数据（文档、块、补丁、历史记录等），并重新从代码库生成。此操作不可撤销。',
    wikiReinitConfirm: '确认重新初始化',
    wikiContinueGenerate: '继续生成',
    wikiRegenerating: '重新生成中…',
    wikiRegenerate: '重新生成',
    wikiGenerationIncomplete: '生成未完成 ({done}/{total} 篇已完成)',
    wikiAnalyzing: '正在分析代码库…',
    wikiOutlineReady: '目录结构已就绪，正在准备生成内容…',
    wikiWriting: '文档内容生成中… ({done}/{total} 篇已完成)',
    wikiPhaseStarting: '正在启动生成任务…',
    wikiPhaseAnalyzing: '正在分析代码库，请稍候…',
    wikiPhaseOutlineReady: '目录结构已生成，正在填充内容…',
    wikiPhaseAgentAnalyzing: 'Agent 正在分析代码库…',
    wikiOutlineScanComplete: '扫描完成！',
    wikiOutlineExplore: '正在探索代码结构…',
    wikiOutlineDelegate: '正在深入分析子系统…',
    wikiOutlineSynthesizing: 'AI 正在综合信息，规划文档结构…',
    wikiOutlineSubmit: '正在提交文档大纲…',
    wikiOutlineComplete: '大纲生成完成！',
    wikiPhaseRestarting: '重新启动生成任务…',
    wikiPhaseWriting: '正在撰写文档内容…',
    wikiGenerationFailed: 'Wiki 生成失败，请检查项目配置后重试。',
    wikiGenerationFailedAgain: 'Wiki 生成再次失败，请检查日志。',
    wikiGenerationTimeout: '生成超时，请稍后刷新页面查看结果。',
    wikiGenerationTimeoutShort: '生成超时，请稍后刷新页面。',
    wikiGenerationError: '生成失败，请重试。',
    wikiRetryError: '重试失败。',
    wikiNoDocuments: '暂无文档',
    wikiNoLocalPath: '项目未配置本地路径，无法继续。',
    wikiNoLocalPathRetry: '项目未配置本地路径，无法重新生成。',
    planEmpty: '暂无规划',
    planEmptyDesc: '在文档视图中对 Block 添加 Issue，然后点击「生成规划」创建第一个规划。',
    planStatusDraft: '草案',
    planStatusConfirmed: '已确认',
    planStatusExecuting: '执行中',
    planStatusReviewing: '审查中',
    planStatusCommitting: '提交中',
    planStatusCompleted: '已完成',
    planStatusDiscarded: '已废弃',
    planMore: '+{count} 更多',
    planProgress: '{done}/{total} 完成',
    planGenerating: '生成规划中',
    planPhaseAnalyzing: '分析 Issues',
    planPhaseReadingSource: '读取源码',
    planPhasePlanning: '规划节点',
    planPhaseSubmitting: '提交规划',
    planFailedTitle: '规划生成失败',
    planUnknownError: '未知错误',
    planRetry: '重试',
    planAnalyzingIssues: '正在分析的 Issues',
    planActivityLog: '活动日志',
    planAgentThinking: 'Agent 正在思考…',
    planNodesPreview: '规划节点预览',
    planSelectHint: '从左侧选择一个规划查看详情',
    planExecutingTitle: '执行中',
    planCompletedTitle: '规划完成',
    planNodeCount: '{count} 个节点',
    planDoneCount: '{done}/{total} 完成',
    planDraftTitle: '规划草案',
    planDraftDiscard: '放弃',
    planDraftConfirm: '确认执行',
    planEditNodeTitle: '编辑节点',
    planEditTitle: '标题',
    planEditDescription: '描述',
    planEditExpectedFiles: '预期文件（逗号分隔）',
    sessionNoActive: '无活跃会话',
    sessionDeleteAgentConfirm: '删除 agent 会话「{label}」？这会中断当前运行，并删除其事件、消息、步骤和子会话。',
    sessionDeleteConfirm: '删除「{title}」及其所有子会话？此操作不可撤销。',
    sessionDeleteFailed: '删除会话失败',
    sessionDeleteAgent: '删除 agent 会话',
    sessionDelete: '删除',
    sessionClearInactive: '清理不活跃会话',
    sessionDeleteConfirm: '删除「{title}」及其所有子会话？此操作不可撤销。',
    sessionSearch: '搜索会话…',
    sessionNoResults: '没有找到会话',
    sessionLoadMore: '加载更多',
    sessionBuiltin: '内建',
    sessionPause: '暂停',
    sessionResume: '恢复',
    sessionCancel: '取消',
    sessionNoRecords: '暂无执行记录',
    sessionPausedHint: '会话已暂停，可随时恢复执行',
    sessionNoPlans: '暂无规划',
    sessionNoOutput: '暂无工作产出',
    subSessionDetails: '详情',
    subSessionRunning: '执行中...',
    subSessionNoResult: '暂无结果',
    permRead: '读取',
    permWrite: '写入',
    permExternalExecution: '外部执行',
    permHighRisk: '高风险',
    permAllowOnce: '允许一次',
    permAlwaysAllow: '始终允许',
    permAlwaysAllowHint: '后续相同操作将自动通过',
    permReject: '拒绝',
    cardSyncing: '同步中',
    cardFailed: '失败',
    cardIdle: '空闲',
    cardDeleteTitle: '删除项目',
    cardNodes: '{count} 节点',
    cardSessions: '{count} 会话',
    cardRuns: '{count} 运行',
    cardEnter: '进入',
    cardJustNow: '刚刚',
    cardMinutesAgo: '{count}分钟前',
    cardHoursAgo: '{count}小时前',
    cardDaysAgo: '{count}天前',
  },
  en: {
    appProjectSpace: 'Project Space',
    appProjectNotSelected: 'No project selected',
    appGlobalHome: 'Global Home',
    appReturnHome: 'Back to home',
    appExpandSidebar: 'Expand sidebar',
    appCollapseSidebar: 'Collapse sidebar',
    appProfile: 'Profile',
    appTeamManagement: 'Team Management',
    appSettings: 'Settings',
    appSwitchLightTheme: 'Switch to light theme',
    appSwitchDarkTheme: 'Switch to dark theme',
    appCreateProject: 'Create Project',
    appContextLinks: 'Context Links',
    homeTitle: '{count} projects running',
    homeSubtitle: 'The full arc, from "not sure yet" to "evidence-proven": Rumbling holds your intent, truth, and direction — at any level of abstraction.',
    homeMyProjects: 'My Projects',
    homeTodayFocus: 'Needs your decision',
    homeNoPriorityBlockers: 'Nothing needs your decision right now.',
    homeRecentEvents: 'Reality Stream',
    homeCreateProject: 'Create project',
    homeCreateProjectHint: 'Create from scratch or import quickly from GitHub / GitLab.',
    homeNoProjectsYet: 'No projects yet. Create one to get started.',
    homeIntentDiff: 'Intent vs Reality',
    homeIntentDiffHint: 'The gap between your current intent and what the codebase reflects',
    homeAttentionInbox: 'Attention Inbox',
    homeAttentionInboxHint: 'Only what requires your judgment — everything else is handled by agents',
    homeAgentRuns: 'Agent Runs',
    homeNoAttentionItems: 'Nothing needs your decision right now.',
    settingsTitle: 'Settings',
    settingsIntro: 'Core shell settings: theme, default home, and notification preferences. Manage members and roles in Team Management.',
    settingsTheme: 'Theme',
    settingsLanguage: 'Language',
    settingsDefaultHome: 'Default landing page',
    settingsGlobalHome: 'Global Home',
    settingsRecentProject: 'Recent Project',
    settingsNotifications: 'Notifications',
    settingsNotificationsHint: 'Receive risk and status change alerts',
    settingsMembersAndPermissions: 'Members & Permissions',
    settingsCurrentRole: 'Current platform role',
    settingsMemberStatus: 'Member status',
    settingsGoTeam: 'Go to Team Management',
    projectCreateTitle: 'Create Project',
    projectCreateIntro: 'Create a blank project or import quickly from a GitHub / GitLab repository.',
    projectCreateNoPermission: 'You do not have permission to create projects.',
    projectCreateStepSource: 'Source',
    projectCreateStepRepo: 'Repository',
    projectCreateStepBasics: 'Basics',
    projectCreateStepImport: 'Import',
    projectCreateSourceScratch: 'Blank Project',
    projectCreateSourceScratchHint: 'Create an empty project and configure context manually.',
    projectCreateSourceGithubHint: 'Import metadata from a GitHub repository.',
    projectCreateSourceGitlabHint: 'Import metadata from a GitLab repository.',
    projectCreateScratchSkipRepo: 'No repository is needed for blank projects.',
    projectCreateSelectConnection: 'Select connection',
    projectCreateSearchRepo: 'Search repository',
    projectCreateLoadingRepos: 'Loading repositories...',
    projectCreateNoRepos: 'No repositories found',
    projectCreateBranch: 'Branch (default main)',
    projectCreateProjectName: 'Project name',
    projectCreateProjectDescription: 'Project description (optional)',
    projectCreateImportReadme: 'Import README as initial Wiki content',
    projectCreateImportIssues: 'Import issues as spec placeholders',
    projectCreateSubscribeWebhooks: 'Subscribe to CI / PR / Issue events',
    projectCreateDefaultAiIntegration: 'Default AI integration (optional)',
    projectCreateNoDefaultAiIntegration: 'No default AI integration',
    projectCreateCancel: 'Cancel',
    projectCreatePrev: 'Back',
    projectCreateNext: 'Next',
    projectCreateSubmit: 'Create project',
    projectCreateSubmitting: 'Creating...',
    projectPulseContext: 'Pulse',
    projectPlanContext: 'Plan (projection)',
    projectKnowledgeContext: 'Knowledge',
    projectArchitectureContext: 'Memory',
    projectSpecsContext: 'Specs',
    intentLayerAspiration: 'Aspiration',
    intentLayerAspirationHint: 'Vision / hypothesis — cannot receive Agent Runs directly',
    intentLayerExecutable: 'Executable',
    intentLayerExecutableHint: 'Concrete, verifiable — can receive Agent Runs',
    intentFalsifiableBy: 'What Reality would falsify it',
    projectOverview: 'Project Overview',
    projectUpdated: 'updated',
    projectAgents: 'agents',
    projectHealth: 'health',
    projectRisks: 'risks',
    projectCurrentContext: 'Current context: ',
    projectIntentMap: 'Coordinates',
    projectAgentRuns: 'Agent Runs',
    archTabOverview: 'Structure',
    archTabDecisions: 'Decisions',
    archTabDrift: 'Drift',
    archTabKnowledge: 'Knowledge',
    archTabOverviewHint: 'Components, stack, and dependencies — the memory base for the next agent run',
    archTabDecisionsHint: 'ADRs: each decision is a boundary for agent action',
    archTabDriftHint: 'Gaps between intent and reality, waiting for your ruling',
    archTabKnowledgeHint: 'Runbooks, guides and API memory for future agent reuse',
    memoryTitle: 'Memory · Agent Long-Term Memory',
    memorySubtitle: 'What is stored here is the context agents read before their next run. Keep it accurate so agents make correct decisions.',
    archOverviewStack: 'Tech Stack',
    archOverviewComponents: 'Components',
    archOverviewDependencies: 'Dependencies',
    archOverviewAutoDetected: 'auto-detected',
    archOverviewManual: 'manual',
    archOverviewEmpty: 'No architecture components yet',
    archKindFrontend: 'Frontend',
    archKindService: 'Service',
    archKindWorker: 'Worker',
    archKindDatastore: 'Datastore',
    archKindExternal: 'External',
    archKindModule: 'Module',
    archDriftTotal: 'Open drifts',
    archDriftEmpty: 'No architecture drift detected',
    archDriftAction: 'Suggested action',
    archDriftSource: 'Source',
    archDriftSeverityHigh: 'high',
    archDriftSeverityMedium: 'medium',
    archDriftSeverityLow: 'low',
    archDriftKindAdr: 'ADR mismatch',
    archDriftKindDependency: 'Dependency drift',
    archDriftKindStack: 'Stack drift',
    archDriftKindInterface: 'Interface drift',
    archDriftUpdateDesign: 'Update design',
    archDriftFixCode: 'File code fix',
    archDriftIgnore: 'Dismiss',
    archDecisionCreateTitle: 'Create ADR',
    archDecisionCreateHint: 'Capture architecture decisions and trace links',
    archDecisionFieldTitle: 'Title',
    archDecisionFieldContext: 'Context',
    archDecisionFieldDecision: 'Decision',
    archDecisionFieldConsequences: 'Consequences',
    archDecisionFieldReqs: 'Linked specs (comma separated)',
    archDecisionCancel: 'Cancel',
    archDecisionSubmit: 'Create ADR',
    archOverviewDetailSummary: 'Component summary',
    archOverviewDetailDependenciesOut: 'Outgoing dependencies',
    archOverviewDetailDependenciesIn: 'Incoming dependencies',
    archOverviewDetailNone: 'None',
    settingsLayoutTitle: 'Layout & Appearance',
    settingsDarkMode: 'Dark mode',
    settingsThemeHint: 'Toggle interface theme',
    settingsLanguageHint: 'Interface display language',
    settingsDefaultHomeHint: 'Content shown when app opens',
    settingsLastProject: 'Last project',
    settingsEditor: 'File viewer',
    settingsEditorHint: 'Editor used when clicking source links',
    settingsSystemConfig: 'System Configuration',
    appSearch: 'Search',
    wikiSearchPlaceholder: 'Press command + k to search documents and content...',
    wikiSearchNoResults: 'No matching content found',
    wikiSearchHint: 'Type to search all documents',
    appHome: 'Home',
    appLightMode: 'Light mode',
    appDarkMode: 'Dark mode',
    appImportProject: 'Import project',
    appSwitchProject: 'Switch project',
    appRemoveProject: 'Remove project',
    appRemoveProjectConfirm: 'Remove "{name}"? Project config and metadata will be permanently deleted. This cannot be undone.',
    appRemoveProjectRunning: 'This project is currently running. It will be closed and all connections interrupted before removal.',
    appCancel: 'Cancel',
    appConfirmRemove: 'Confirm remove',
    appRemoving: 'Removing…',
    appNeedProject: 'Select a project first',
    wikiDocument: 'Document',
    wikiPlan: 'Plan',
    welcomeImportHint: 'Import a project to get started',
    welcomeConnectHint: 'Connect your code repository to start analyzing and collaborating',
    commonSave: 'Save',
    commonSaving: 'Saving...',
    commonSaved: 'Saved',
    commonAdd: 'Add',
    commonCancel: 'Cancel',
    commonDelete: 'Delete',
    commonDeleting: 'Deleting…',
    commonConfirmDelete: 'Confirm delete',
    commonClose: 'Close panel',
    commonFlipPanel: 'Flip panel position (left/right)',
    commonSearch: 'Search',
    commonLoading: 'Loading...',
    commonCustom: 'Custom',
    panelSearch: 'Search',
    panelSettings: 'Settings',
    panelProjects: 'Projects',
    titlebarSessions: 'Sessions',
    titlebarNotifications: 'Notifications',
    projectLoadingTitle: 'Loading project…',
    projectLoadingDesc: 'Fetching project info from server',
    projectUnknown: 'Unknown project',
    projectNotFound: 'Project not found. It may have been deleted or the ID is incorrect.',
    projectNotInList: 'Project not in list. Return to home to sync.',
    projectNavConfig: 'Project Config',
    projectSearchPlaceholder: 'Search projects…',
    projectNoMatch: 'No matching projects',
    projectNone: 'No projects',
    projectDeleteTitle: 'Delete project "{name}"',
    projectDeleteIrreversible: 'This action cannot be undone.',
    projectDeleteGitWarning: 'Cloned code in the Git working directory will also be removed.',
    settingsProjectTitle: 'Project Settings',
    settingsProjectBack: 'Back to project',
    settingsTabBasics: 'Basics',
    settingsTabCollaboration: 'Collaboration',
    settingsTabNotifications: 'Notifications',
    settingsTabCompliance: 'Compliance',
    settingsLimitsTitle: 'Runtime Limits',
    settingsMaxAgents: 'Max agents per project',
    settingsMaxAgentsDesc: 'Maximum concurrent agents allowed per project',
    settingsAgentTimeout: 'Agent timeout (seconds)',
    settingsAgentTimeoutDesc: 'Agent execution timeout',
    settingsAdvancedTitle: 'Advanced',
    settingsShowSessionsTab: 'Show Sessions panel',
    settingsShowSessionsTabDesc: 'Display the Sessions debug panel in the navigation bar',
    settingsAllowProjectOverride: 'Allow project connection overrides',
    settingsAllowProjectOverrideDesc: 'Projects can customize ACP connection config',
    settingsOpenConfigFile: 'Open config file',
    settingsOpenConfigFileDesc: 'Open the JSON config file in your system editor — changes sync automatically on save',
    settingsAcpTitle: 'ACP',
    settingsAcpRefresh: 'Refresh detection',
    settingsAcpRefreshing: 'Detecting',
    settingsAcpEmpty: 'No ACP endpoints found. Click refresh to retry.',
    settingsAcpAvailable: 'Available',
    settingsAcpInstalled: 'Installed',
    settingsAcpMissing: 'Not installed',
    settingsAcpFailed: 'Failed',
    settingsMcpTitle: 'MCP Config',
    settingsMcpComingSoon: 'Coming soon',
    settingsMcpDesc: 'MCP (Model Context Protocol) server configuration will be supported in a future release.',
    llmConfigError: 'LLM configuration error',
    llmConfigErrorGoSettings: 'Go to settings',
    llmNoProviderConfigured: 'No LLM provider configured. Please configure one in settings.',
    llmProviderAdd: 'Add',
    llmProviderCustom: 'Custom',
    llmProviderEmpty: 'No providers configured. Click Add to get started.',
    llmProviderSaveFailed: 'Save failed',
    llmProviderSaveSuccess: '✓ Connected and saved',
    llmProviderConnectFailed: 'Connection failed, not saved',
    llmProviderDiscoverCount: 'Found {count} models',
    llmProviderDiscoverFailed: 'Discovery failed',
    llmProviderRequestFailed: 'Request failed',
    llmCardDefault: 'Default',
    llmCardSetDefault: 'Set as default',
    llmCardSave: 'Save provider',
    llmCardValidate: 'Test connection',
    llmCardDelete: 'Delete',
    llmCardDiscover: 'Discover',
    llmCardModel: 'Model',
    llmCardApiKeyPlaceholder: 'Enter API Key',
    basicsProjectName: 'Project name',
    basicsEnvironment: 'Environment',
    basicsDescription: 'Description',
    basicsDescriptionPlaceholder: 'Project description...',
    basicsVisibility: 'Visibility',
    basicsOwner: 'Owner',
    basicsMemberId: 'Member ID',
    basicsTags: 'Tags',
    basicsAddTagPlaceholder: 'Add tag...',
    collabAgentPermissions: 'Agent Permissions',
    collabAllowDirectCommit: 'Allow agents to commit directly',
    collabReviewPolicy: 'Review Policy',
    collabMinApprovals: 'Minimum approvals',
    collabRequireQa: 'Require QA approval',
    collabRequireOwner: 'Require owner approval',
    collabBlockOnCi: 'Block merge on failed CI',
    notifChannel: 'Notification channel',
    notifChannelNone: 'Off',
    notifMinSeverity: 'Minimum severity',
    notifQuietHours: 'Quiet hours',
    notifQuietHoursPlaceholder: 'e.g. 22:00-08:00',
    notifRecipients: 'Recipients',
    notifAddRecipientPlaceholder: 'Add recipient...',
    complianceRetentionDays: 'Data retention (days)',
    complianceAuditLog: 'Enable audit log',
    complianceDataExport: 'Allow data export',
    compliancePiiMasking: 'PII masking',
    providerAcpOverride: 'ACP Provider Override',
    providerInheritGlobal: 'Inherit global ({id})',
    providerUseDefault: 'Use default',
    providerConnectionOverride: 'Connection Override',
    providerInheritGlobalPlaceholder: 'Inherit global',
    providerLimitsOverride: 'Limits Override',
    providerMaxAgents: 'Max agents',
    providerTimeout: 'Timeout (seconds)',
    wikiEmpty: 'No Wiki yet',
    wikiEmptyDesc: "This project doesn't have a Codebase Design Wiki yet.",
    wikiEmptyDescLine2: 'Click the button below to let AI analyze the codebase and generate structured design docs.',
    wikiGenerating: 'Generating…',
    wikiGenerate: 'Generate Wiki',
    wikiFailedTitle: 'Wiki generation failed',
    wikiFailedDesc: 'The last generation task failed, possibly due to code analysis or LLM errors.',
    wikiRetrying: 'Regenerating…',
    wikiRetry: 'Regenerate',
    wikiPlans: 'Plans',
    wikiDocuments: 'Documents',
    wikiSelectDocument: 'Select a document from the left',
    wikiReinitConfirmTitle: 'Confirm Reinitialize',
    wikiReinitConfirmDesc: 'This will delete all Wiki data for this project (documents, blocks, patches, history, etc.) and regenerate from the codebase. This cannot be undone.',
    wikiReinitConfirm: 'Confirm Reinitialize',
    wikiContinueGenerate: 'Continue generating',
    wikiRegenerating: 'Regenerating…',
    wikiRegenerate: 'Regenerate',
    wikiGenerationIncomplete: 'Incomplete ({done}/{total} docs done)',
    wikiAnalyzing: 'Analyzing codebase…',
    wikiOutlineReady: 'Outline ready, preparing to generate content…',
    wikiWriting: 'Generating content… ({done}/{total} docs done)',
    wikiPhaseStarting: 'Starting generation task…',
    wikiPhaseAnalyzing: 'Analyzing codebase, please wait…',
    wikiPhaseOutlineReady: 'Outline generated, filling in content…',
    wikiPhaseAgentAnalyzing: 'Agent is analyzing the codebase…',
    wikiOutlineScanComplete: 'Scan complete!',
    wikiOutlineExplore: 'Exploring code structure…',
    wikiOutlineDelegate: 'Deep-diving into subsystems…',
    wikiOutlineSynthesizing: 'AI synthesizing and planning document structure…',
    wikiOutlineSubmit: 'Submitting document outline…',
    wikiOutlineComplete: 'Outline complete!',
    wikiPhaseRestarting: 'Restarting generation task…',
    wikiPhaseWriting: 'Writing document content…',
    wikiGenerationFailed: 'Wiki generation failed. Check project config and retry.',
    wikiGenerationFailedAgain: 'Wiki generation failed again. Check logs.',
    wikiGenerationTimeout: 'Generation timed out. Refresh the page later.',
    wikiGenerationTimeoutShort: 'Generation timed out. Refresh the page.',
    wikiGenerationError: 'Generation failed. Please retry.',
    wikiRetryError: 'Retry failed.',
    wikiNoDocuments: 'No documents yet',
    wikiNoLocalPath: 'Project has no local path configured.',
    wikiNoLocalPathRetry: 'Project has no local path configured for regeneration.',
    planEmpty: 'No plans yet',
    planEmptyDesc: 'Add issues to blocks in document view, then click "Generate Plan" to create your first plan.',
    planStatusDraft: 'Draft',
    planStatusConfirmed: 'Confirmed',
    planStatusExecuting: 'Executing',
    planStatusReviewing: 'Reviewing',
    planStatusCommitting: 'Committing',
    planStatusCompleted: 'Completed',
    planStatusDiscarded: 'Discarded',
    planMore: '+{count} more',
    planProgress: '{done}/{total} done',
    planGenerating: 'Generating plan',
    planPhaseAnalyzing: 'Analyzing Issues',
    planPhaseReadingSource: 'Reading source',
    planPhasePlanning: 'Planning nodes',
    planPhaseSubmitting: 'Submitting plan',
    planFailedTitle: 'Plan generation failed',
    planUnknownError: 'Unknown error',
    planRetry: 'Retry',
    planAnalyzingIssues: 'Analyzing Issues',
    planActivityLog: 'Activity log',
    planAgentThinking: 'Agent is thinking…',
    planNodesPreview: 'Plan nodes preview',
    planSelectHint: 'Select a plan from the left to view details',
    planExecutingTitle: 'Executing',
    planCompletedTitle: 'Plan completed',
    planNodeCount: '{count} nodes',
    planDoneCount: '{done}/{total} done',
    planDraftTitle: 'Plan draft',
    planDraftDiscard: 'Discard',
    planDraftConfirm: 'Confirm execution',
    planEditNodeTitle: 'Edit node',
    planEditTitle: 'Title',
    planEditDescription: 'Description',
    planEditExpectedFiles: 'Expected files (comma-separated)',
    sessionNoActive: 'No active sessions',
    sessionDeleteAgentConfirm: 'Delete agent session "{label}"? This will interrupt the current run and delete its events, messages, steps, and sub-sessions.',
    sessionDeleteConfirm: 'Delete "{title}" and all its sub-sessions? This cannot be undone.',
    sessionDeleteFailed: 'Failed to delete session',
    sessionDeleteAgent: 'Delete agent session',
    sessionDelete: 'Delete',
    sessionClearInactive: 'Clear Inactive Sessions',
    sessionSearch: 'Search sessions…',
    sessionNoResults: 'No sessions found',
    sessionLoadMore: 'Load more',
    sessionBuiltin: 'Built-in',
    sessionPause: 'Pause',
    sessionResume: 'Resume',
    sessionCancel: 'Cancel',
    sessionNoRecords: 'No execution records',
    sessionPausedHint: 'Session paused, can be resumed at any time',
    sessionNoPlans: 'No plans',
    sessionNoOutput: 'No work output',
    subSessionDetails: 'Details',
    subSessionRunning: 'Running...',
    subSessionNoResult: 'No result',
    permRead: 'Read',
    permWrite: 'Write',
    permExternalExecution: 'External execution',
    permHighRisk: 'High risk',
    permAllowOnce: 'Allow once',
    permAlwaysAllow: 'Always allow',
    permAlwaysAllowHint: 'Future identical operations will be auto-approved',
    permReject: 'Reject',
    cardSyncing: 'Syncing',
    cardFailed: 'Failed',
    cardIdle: 'Idle',
    cardDeleteTitle: 'Delete project',
    cardNodes: '{count} nodes',
    cardSessions: '{count} sessions',
    cardRuns: '{count} runs',
    cardEnter: 'Enter',
    cardJustNow: 'just now',
    cardMinutesAgo: '{count}m ago',
    cardHoursAgo: '{count}h ago',
    cardDaysAgo: '{count}d ago',
  },
} as const

export type I18nKey = keyof (typeof messages)['zh']

export function t(locale: Locale, key: I18nKey, vars?: Record<string, string | number>): string {
  const table = messages[locale] ?? messages.zh
  let raw: string = table[key] ?? messages.zh[key]
  if (!vars) return raw
  for (const [name, value] of Object.entries(vars)) {
    raw = raw.split(`{${name}}`).join(String(value))
  }
  return raw
}
