fix(i18n): translate the Delete question, prompt labels and the shortcut recorder placeholder (#1116)

The project tree's Delete question was concatenated from English fragments, and the VCS prompt / multi-choice labels and the shortcut recorder placeholder were rendered as given, so they stayed English in the Chinese UI. The question is now tx templates with zh entries; the labels and placeholder go through the catalog.
This commit is contained in:
l0ng-ai
2026-11-04 07:55:44 +08:00
committed by GitHub
parent 94665528b9
commit a1dd16f26d
4 changed files with 27 additions and 7 deletions
+10 -4
View File
@@ -294,8 +294,14 @@ async function refreshAfterCreate(parent: string, path: string) {
// ---------------------------------------------------------------------------
// Delete
function describe(paths: string[]): string {
return paths.length === 1 ? `'${nameOf(paths[0]!)}'` : `${paths.length} items`;
/** The Delete dialog's question, e.g. "Delete 'src' and its contents?". */
function deleteQuestion(paths: string[], folders: boolean): string {
if (paths.length === 1) {
const name = nameOf(paths[0]!);
return folders ? tx`Delete '${name}' and its contents?` : tx`Delete '${name}'?`;
}
const count = paths.length;
return folders ? tx`Delete ${count} items (including folder contents)?` : tx`Delete ${count} items?`;
}
/** Visible rows in display order (roots, then children of expanded folders). */
@@ -441,9 +447,9 @@ export async function deleteSelection(nodes: ProjectNode[] = selectedNodes()) {
message: createElement(
Fragment,
null,
`Delete ${describe(paths)}${folders ? (paths.length === 1 ? " and its contents" : " (including folder contents)") : ""}?`,
deleteQuestion(paths, folders > 0),
createElement("br"),
"Items are moved to the Trash.",
tx("Items are moved to the Trash."),
),
});
if (!answer) return;
@@ -5,6 +5,7 @@
import { forwardRef, useEffect, useRef, type KeyboardEvent } from "react";
import clsx from "clsx";
import { formatBinding, strokeOf, suspendKeyboardDispatch } from "@/platform/keymap";
import { T } from "@/ui";
import styles from "./Keymap.module.css";
export interface StrokeRecorderProps {
@@ -81,7 +82,9 @@ export const StrokeRecorder = forwardRef<HTMLDivElement, StrokeRecorderProps>(fu
{value ? (
<span className={styles.recorded}>{formatBinding(value)}</span>
) : (
<span className={styles.recorderPlaceholder}>{placeholder}</span>
<span className={styles.recorderPlaceholder}>
<T>{placeholder}</T>
</span>
)}
</div>
);
+8 -2
View File
@@ -94,7 +94,11 @@ function PromptDialog(props: PromptOptions & { onDone: (r: PromptResult | null)
submit();
}}
>
{label && <label className={styles.fieldLabel}>{label}</label>}
{label && (
<label className={styles.fieldLabel}>
<T>{label}</T>
</label>
)}
<Input
data-autofocus
aria-label={label ?? title}
@@ -216,7 +220,9 @@ function ChooseManyDialog(props: ChooseManyOptions & { onDone: (r: string[] | nu
</div>
{customLabel && (
<>
<label className={styles.fieldLabel}>{customLabel}</label>
<label className={styles.fieldLabel}>
<T>{customLabel}</T>
</label>
<Input aria-label={customLabel} value={custom} onChange={(e) => setCustom(e.target.value)} />
</>
)}
+5
View File
@@ -649,6 +649,11 @@
"Default value": "默认值",
"Definition": "定义",
"Delete": "删除",
"Delete '{name}'?": "删除 '{name}'?",
"Delete '{name}' and its contents?": "删除 '{name}' 及其内容?",
"Delete {count} items?": "删除 {count} 个项目?",
"Delete {count} items (including folder contents)?": "删除 {count} 个项目(包括文件夹内容)?",
"Items are moved to the Trash.": "项目将被移到回收站。",
"Delete Anyway": "仍然删除",
"Delete Bookmark": "删除书签",
"Delete Branch": "删除分支",