fix(approval-prompts): translate Shell/Path confirm title and action labels#1561
Merged
Conversation
…labels (#1560) `toApprovalPrompt` in core-utils mints English labels so the ACP surface (no i18n layer) can render immediately — but the CLI surface was rendering those English strings verbatim, leaving "Run command" / "Run once" / "Always allow — …" / "Deny" on screen even when the locale was zh-CN. ShellConfirm and PathConfirm now override `prompt.title` and each `action.label` with locally-translated strings keyed off `action.id` and `prompt.data` (so we can still tell foreground vs background and read vs write apart, even after the unified `prompt.kind` collapses each pair). New i18n keys in both EN.ts and zh-CN.ts: - `shellConfirm.promptTitleRunCommand` / `promptTitleRunBackground` - `shellConfirm.actionRunOnce` / `actionAlwaysAllow` (with `{prefix}`) / `actionDeny` - `pathConfirm.promptTitleRead` / `promptTitleWrite` - `pathConfirm.actionAllowRead` / `actionAllowWrite` / `actionAlwaysAllow` / `actionDeny` Test plan: - `tests/shell-confirm-render.test.tsx` gains a `setLanguageRuntime("zh-CN")` case that asserts 运行命令 / 运行一次 / 始终允许 / 拒绝 render and the English labels do NOT survive. - `npm run verify` passes (3554 tests). Closes #1560
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Issue #1560: when running the CLI in zh-CN, the shell-approval card still showed
Run command/Run once/Always allow — …/Denyin English.toApprovalPrompt(core-utils) mints English labels deliberately so the ACP surface (no i18n layer) can render immediately, but the CLI surface was rendering those verbatim instead of running them through the active locale.Fix
ShellConfirmandPathConfirmnow overrideprompt.titleand eachaction.labelwith locally-translated strings keyed offaction.idplusprompt.data— that's how we still tell foreground vs background and read vs write apart even though the unifiedprompt.kindcollapses both pairs into"shell"and"path".New i18n keys (both
EN.tsandzh-CN.ts, plus the type defs intypes.ts):shellConfirm.promptTitleRunCommand/promptTitleRunBackgroundshellConfirm.actionRunOnce/actionAlwaysAllow(with{prefix}) /actionDenypathConfirm.promptTitleRead/promptTitleWritepathConfirm.actionAllowRead/actionAllowWrite/actionAlwaysAllow/actionDenyTest plan
setLanguageRuntime("zh-CN")case intests/shell-confirm-render.test.tsx— asserts 运行命令 / 运行一次 / 始终允许 / 拒绝 render and the English labels do NOT survivedata.prefixinterpolation puts the prefix afterAlways allow —, so the existingtoContain("Always allow")assertion still matches)npm run verifypasses (3554 tests)Closes #1560