Files
apes-sidebar/src/client/apes/locales.ts
T
figmar 66ee3953c9 feat(apes): revive the task/message tabs in the info layer
C6 removed apes:tasks as a duplicate of the host session panel; in practice the two answer different questions (host panel = switch workspaces, plugin tab = who is running right now), so the tab is restored and the info layer goes back to five types.

tasks: live session list (current / running / subagent markers) + showInactive toggle via pluginSettings['apes:tasks']; messages: placeholder that states the host has no message feed yet; both get badge counters, and the whole layer now honours the visible gate (auto-collapse) so hidden tabs stop waking on session events.

zh/en/ja dictionaries in sync (AGENTS 5); wiki 02/03/07 reverted from three to five tabs; decision record in docs/plans/2026-10-11-apes-tab-revival.md.
2026-10-11 21:18:08 +08:00

139 lines
5.5 KiB
TypeScript

/**
* apes:* tab i18n — isolated from the upstream `betterSidebar` locale
* namespace (D1 = module B). The fork keeps its own `apes` namespace and
* its own `t()` so that adding apes keys never touches the upstream
* `locales.ts` (whose `CopyKey = keyof typeof zh` is closed over its own
* dicts). The `t()` mirrors the upstream implementation's resolution order
* (active-locale chain → key fallback) but reads the apes dicts; it is NOT
* wired to the better-locale override store in Phase 1 (those third-language
* overrides ride the lazy `locale` chunk that only covers `betterSidebar`
* entries — apes keys fall back to zh/en, which is acceptable for the
* placeholder round and gets the override integration in Phase 2).
*/
/** The apes locale namespace (registered with ctx.locale under this key). */
export const APES_LOCALE_NS = 'apes'
/** The zh dictionary (source of truth). */
export const apesZh = {
// View titles
apesTasksTitle: '任务',
apesMessagesTitle: '消息',
apesAgentsTitle: '智能体',
apesAppsTitle: '应用',
apesProfileTitle: '画像',
// Tasks view
apesTasksShowInactive: '显示空闲会话',
apesTasksEmpty: '当前没有会话',
apesTasksCurrent: '当前',
apesTasksRunning: '运行中',
apesTasksSubagent: '子智能体',
// Messages view
apesMessagesNoFeed: '当前 DSH 版本未提供消息流数据源',
// Agents view
apesAgentsEmpty: '当前会话没有子智能体',
apesAgentsRoot: '主智能体',
apesAgentRunning: '运行中',
apesAgentInactive: '空闲',
apesAgentOneShot: '一次性',
apesAgentContinuable: '可续',
// Profile view
apesProfileCurrent: '当前会话',
apesProfileCwd: '工作目录',
apesProfileNoCwd: '未知',
apesProfileRunning: '运行中',
apesProfileIdle: '空闲',
// Apps view
apesAppsNoFeed: '当前 DSH 版本未提供工作区应用数据源',
apesAppsWorkspace: '工作区',
} as const
/** The en dictionary (checked against zh — every zh key must appear here). */
export const apesEn: Record<keyof typeof apesZh, string> = {
apesTasksTitle: 'Tasks',
apesMessagesTitle: 'Messages',
apesAgentsTitle: 'Agents',
apesAppsTitle: 'Apps',
apesProfileTitle: 'Profile',
apesTasksShowInactive: 'Show idle sessions',
apesTasksEmpty: 'No sessions right now',
apesTasksCurrent: 'current',
apesTasksRunning: 'running',
apesTasksSubagent: 'subagent',
apesMessagesNoFeed: 'This DSH version exposes no message stream feed',
apesAgentsEmpty: 'No subagents in this session',
apesAgentsRoot: 'Main agent',
apesAgentRunning: 'running',
apesAgentInactive: 'idle',
apesAgentOneShot: 'one-shot',
apesAgentContinuable: 'continuable',
apesProfileCurrent: 'Current session',
apesProfileCwd: 'Working directory',
apesProfileNoCwd: 'unknown',
apesProfileRunning: 'running',
apesProfileIdle: 'idle',
apesAppsNoFeed: 'This DSH version exposes no workspace-app feed',
apesAppsWorkspace: 'Workspace',
}
export type ApesCopyKey = keyof typeof apesZh
/**
* The ja dictionary (AGENTS §5: a new zh key must land in ja in the same
* change, otherwise ja readers silently get the en text). Japanese is not a
* separate source of truth — it mirrors the en wording, never the zh one.
*/
export const apesJa: Record<keyof typeof apesZh, string> = {
apesTasksTitle: 'タスク',
apesMessagesTitle: 'メッセージ',
apesAgentsTitle: 'エージェント',
apesAppsTitle: 'アプリ',
apesProfileTitle: 'プロフィール',
apesTasksShowInactive: 'アイドル状態のセッションを表示',
apesTasksEmpty: 'セッションがありません',
apesTasksCurrent: '現在',
apesTasksRunning: '実行中',
apesTasksSubagent: 'サブエージェント',
apesMessagesNoFeed: 'この DSH バージョンはメッセージストリームの供給元を提供していません',
apesAgentsEmpty: 'このセッションにサブエージェントはいません',
apesAgentsRoot: 'メインエージェント',
apesAgentRunning: '実行中',
apesAgentInactive: 'アイドル',
apesAgentOneShot: '単発',
apesAgentContinuable: '継続可',
apesProfileCurrent: '現在のセッション',
apesProfileCwd: '作業ディレクトリ',
apesProfileNoCwd: '不明',
apesProfileRunning: '実行中',
apesProfileIdle: 'アイドル',
apesAppsNoFeed: 'この DSH バージョンはワークスペースアプリのデータ源を提供していません',
apesAppsWorkspace: 'ワークスペース',
}
/** Resolve the currently active DSH locale ('zh' | 'ja' | 'en' today). */
export function attachApesLocale(service: { getSnapshot(): { active: string } } | undefined): void {
apesLocaleService = service
}
let apesLocaleService: { getSnapshot(): { active: string } } | undefined
/**
* Translate an apes key. Resolution order: active-locale chain (zh dict when
* the DSH preference is zh*, ja dict when it is ja*, en dict otherwise) → key
* fallback (shows the key itself rather than `undefined`). Mirrors the
* upstream t() minus the better-locale override (Phase 2).
*/
export function t(key: ApesCopyKey, params?: Record<string, string | number>): string {
const active = apesLocaleService?.getSnapshot().active ?? 'zh'
const lang = active.toLowerCase()
const dict = lang.startsWith('zh') ? apesZh : lang.startsWith('ja') ? apesJa : apesEn
let text: string | undefined = dict[key]
if (text === undefined) text = key
if (params !== undefined) {
for (const [name, value] of Object.entries(params)) {
text = text.replaceAll(`{${name}}`, String(value))
}
}
return text
}