From 8a298c5fd203e7f802e3f3abd0e36cf5a2b0e48a Mon Sep 17 00:00:00 2001 From: Z User Date: Tue, 16 Jun 2026 02:15:10 +0000 Subject: [PATCH] fix: add i18n to 3 more TUI dialog components - dialog-session-delete-failed.tsx: Replace 6 hardcoded English strings with t() calls (title, description, 2 option titles, 2 option descriptions) - dialog-workspace-unavailable.tsx: Replace 4 hardcoded English strings with t() calls (title, description, prompt, 2 button labels) - plugin-route-missing.tsx: Replace 2 hardcoded English strings with t() calls - Add 15 new i18n keys to en.ts and zh.ts (tui.delete_failed.*, tui.workspace_unavailable.*, tui.plugin_route_missing.*) --- .../dialog-session-delete-failed.tsx | 16 +++++++------- .../dialog-workspace-unavailable.tsx | 13 ++++++++---- .../tui/component/plugin-route-missing.tsx | 6 ++++-- packages/opencode/src/cli/cmd/tui/i18n/en.ts | 21 ++++++++++++++++++- packages/opencode/src/cli/cmd/tui/i18n/zh.ts | 19 +++++++++++++++++ 5 files changed, 61 insertions(+), 14 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/component/dialog-session-delete-failed.tsx b/packages/opencode/src/cli/cmd/tui/component/dialog-session-delete-failed.tsx index 4a22a0c4..dc774e1a 100644 --- a/packages/opencode/src/cli/cmd/tui/component/dialog-session-delete-failed.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/dialog-session-delete-failed.tsx @@ -4,6 +4,7 @@ import { useDialog } from "../ui/dialog" import { createStore } from "solid-js/store" import { For } from "solid-js" import { useKeyboard } from "@opentui/solid" +import { useLanguage } from "@tui/context/language" export function DialogSessionDeleteFailed(props: { session: string @@ -14,6 +15,7 @@ export function DialogSessionDeleteFailed(props: { }) { const dialog = useDialog() const { theme } = useTheme() + const { t } = useLanguage() const [store, setStore] = createStore({ active: "delete" as "delete" | "restore", }) @@ -21,14 +23,14 @@ export function DialogSessionDeleteFailed(props: { const options = [ { id: "delete" as const, - title: "Delete workspace", - description: "Delete the workspace and all sessions attached to it.", + title: t("tui.delete_failed.title_delete"), + description: t("tui.delete_failed.desc_delete"), run: props.onDelete, }, { id: "restore" as const, - title: "Restore to new workspace", - description: "Try to restore this session into a new workspace.", + title: t("tui.delete_failed.title_restore"), + description: t("tui.delete_failed.desc_restore"), run: props.onRestore, }, ] @@ -56,17 +58,17 @@ export function DialogSessionDeleteFailed(props: { - Failed to Delete Session + {t("tui.delete_failed.title")} dialog.clear()}> esc - {`The session "${props.session}" could not be deleted because the workspace "${props.workspace}" is not available.`} + {t("tui.delete_failed.session_unavailable", { session: props.session, workspace: props.workspace })} - Choose how you want to recover this broken workspace session. + {t("tui.delete_failed.choose_recovery")} diff --git a/packages/opencode/src/cli/cmd/tui/component/dialog-workspace-unavailable.tsx b/packages/opencode/src/cli/cmd/tui/component/dialog-workspace-unavailable.tsx index 7a217985..81efe308 100644 --- a/packages/opencode/src/cli/cmd/tui/component/dialog-workspace-unavailable.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/dialog-workspace-unavailable.tsx @@ -4,10 +4,12 @@ import { createStore } from "solid-js/store" import { For } from "solid-js" import { useTheme } from "../context/theme" import { useDialog } from "../ui/dialog" +import { useLanguage } from "@tui/context/language" export function DialogWorkspaceUnavailable(props: { onRestore?: () => boolean | void | Promise }) { const dialog = useDialog() const { theme } = useTheme() + const { t } = useLanguage() const [store, setStore] = createStore({ active: "restore" as "cancel" | "restore", }) @@ -40,6 +42,7 @@ export function DialogWorkspaceUnavailable(props: { onRestore?: () => boolean | evt.preventDefault() evt.stopPropagation() setStore("active", "restore") + return } }) @@ -47,17 +50,17 @@ export function DialogWorkspaceUnavailable(props: { onRestore?: () => boolean | - Workspace Unavailable + {t("tui.workspace_unavailable.title")} dialog.clear()}> esc - This session is attached to a workspace that is no longer available. + {t("tui.workspace_unavailable.description")} - Would you like to restore this session into a new workspace? + {t("tui.workspace_unavailable.restore_prompt")} @@ -71,7 +74,9 @@ export function DialogWorkspaceUnavailable(props: { onRestore?: () => boolean | void confirm() }} > - {item} + + {t(`tui.workspace_unavailable.${item}` as any)} + )} diff --git a/packages/opencode/src/cli/cmd/tui/component/plugin-route-missing.tsx b/packages/opencode/src/cli/cmd/tui/component/plugin-route-missing.tsx index 77e2ea8d..12b86910 100644 --- a/packages/opencode/src/cli/cmd/tui/component/plugin-route-missing.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/plugin-route-missing.tsx @@ -1,13 +1,15 @@ import { useTheme } from "../context/theme" +import { useLanguage } from "@tui/context/language" export function PluginRouteMissing(props: { id: string; onHome: () => void }) { const { theme } = useTheme() + const { t } = useLanguage() return ( - Unknown plugin route: {props.id} + {t("tui.plugin_route_missing.unknown", { id: props.id })} - go home + {t("tui.plugin_route_missing.go_home")} ) diff --git a/packages/opencode/src/cli/cmd/tui/i18n/en.ts b/packages/opencode/src/cli/cmd/tui/i18n/en.ts index 68c9eb2a..f72ba025 100644 --- a/packages/opencode/src/cli/cmd/tui/i18n/en.ts +++ b/packages/opencode/src/cli/cmd/tui/i18n/en.ts @@ -428,4 +428,23 @@ export const dict: Record = { "trust.dangerous.advice_root": "Unless you have a very specific reason, DO NOT trust the filesystem root.", "trust.dangerous.option.yes": "I understand the risks, trust for this session", "trust.dangerous.option.no": "Exit (recommended)", -} + // Session delete failed dialog + "tui.delete_failed.title": "Failed to Delete Session", + "tui.delete_failed.session_unavailable": "The session \"{{session}}\" could not be deleted because the workspace \"{{workspace}}\" is not available.", + "tui.delete_failed.choose_recovery": "Choose how you want to recover this broken workspace session.", + "tui.delete_failed.title_delete": "Delete workspace", + "tui.delete_failed.desc_delete": "Delete the workspace and all sessions attached to it.", + "tui.delete_failed.title_restore": "Restore to new workspace", + "tui.delete_failed.desc_restore": "Try to restore this session into a new workspace.", + + // Workspace unavailable dialog + "tui.workspace_unavailable.title": "Workspace Unavailable", + "tui.workspace_unavailable.description": "This session is attached to a workspace that is no longer available.", + "tui.workspace_unavailable.restore_prompt": "Would you like to restore this session into a new workspace?", + "tui.workspace_unavailable.cancel": "cancel", + "tui.workspace_unavailable.restore": "restore", + + // Plugin route missing + "tui.plugin_route_missing.unknown": "Unknown plugin route: {{id}}", + "tui.plugin_route_missing.go_home": "go home" +} \ No newline at end of file diff --git a/packages/opencode/src/cli/cmd/tui/i18n/zh.ts b/packages/opencode/src/cli/cmd/tui/i18n/zh.ts index cf12b5e0..dba39b6c 100644 --- a/packages/opencode/src/cli/cmd/tui/i18n/zh.ts +++ b/packages/opencode/src/cli/cmd/tui/i18n/zh.ts @@ -421,4 +421,23 @@ export const dict = { "trust.dangerous.advice_root": "除非有明确的理由,否则不要信任文件系统根目录。", "trust.dangerous.option.yes": "我了解风险,仅本次信任", "trust.dangerous.option.no": "退出(推荐)", + // Session delete failed dialog + "tui.delete_failed.title": "删除会话失败", + "tui.delete_failed.session_unavailable": "会话 \"{{session}}\" 无法删除,因为工作区 \"{{workspace}}\" 不可用。", + "tui.delete_failed.choose_recovery": "选择如何恢复此损坏的工作区会话。", + "tui.delete_failed.title_delete": "删除工作区", + "tui.delete_failed.desc_delete": "删除工作区及其关联的所有会话。", + "tui.delete_failed.title_restore": "恢复到新工作区", + "tui.delete_failed.desc_restore": "尝试将此会话恢复到新的工作区。", + + // Workspace unavailable dialog + "tui.workspace_unavailable.title": "工作区不可用", + "tui.workspace_unavailable.description": "此会话关联的工作区已不可用。", + "tui.workspace_unavailable.restore_prompt": "是否将此会话恢复到新的工作区?", + "tui.workspace_unavailable.cancel": "取消", + "tui.workspace_unavailable.restore": "恢复", + + // Plugin route missing + "tui.plugin_route_missing.unknown": "未知插件路由:{{id}}", + "tui.plugin_route_missing.go_home": "返回首页" } satisfies Partial>