Skip to content

Commit aba0ac8

Browse files
author
aheizi
committed
add i18n for batch clear history
1 parent 0df6279 commit aba0ac8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+333
-52
lines changed

webview-ui/src/components/history/BatchDeleteTaskDialog.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useCallback } from "react"
2+
import { useAppTranslation } from "@/i18n/TranslationContext"
23
import {
34
AlertDialog,
45
AlertDialogAction,
@@ -18,6 +19,7 @@ interface BatchDeleteTaskDialogProps extends AlertDialogProps {
1819
}
1920

2021
export const BatchDeleteTaskDialog = ({ taskIds, ...props }: BatchDeleteTaskDialogProps) => {
22+
const { t } = useAppTranslation()
2123
const { onOpenChange } = props
2224

2325
const onDelete = useCallback(() => {
@@ -31,24 +33,22 @@ export const BatchDeleteTaskDialog = ({ taskIds, ...props }: BatchDeleteTaskDial
3133
<AlertDialog {...props}>
3234
<AlertDialogContent className="max-w-md">
3335
<AlertDialogHeader>
34-
<AlertDialogTitle>Delete Tasks</AlertDialogTitle>
36+
<AlertDialogTitle>{t("history:deleteTasks")}</AlertDialogTitle>
3537
<AlertDialogDescription className="text-vscode-foreground">
36-
<div className="mb-2">
37-
Are you sure you want to delete <strong>{taskIds.length}</strong> selected tasks?
38-
</div>
38+
<div className="mb-2">{t("history:confirmDeleteTasks", { count: taskIds.length })}</div>
3939
<div className="text-vscode-editor-foreground bg-vscode-editor-background p-2 rounded text-sm">
40-
This action cannot be undone. All selected tasks will be permanently deleted.
40+
{t("history:deleteTasksWarning")}
4141
</div>
4242
</AlertDialogDescription>
4343
</AlertDialogHeader>
4444
<AlertDialogFooter>
4545
<AlertDialogCancel asChild>
46-
<Button variant="secondary">Cancel</Button>
46+
<Button variant="secondary">{t("common:cancel")}</Button>
4747
</AlertDialogCancel>
4848
<AlertDialogAction asChild>
4949
<Button variant="destructive" onClick={onDelete}>
5050
<span className="codicon codicon-trash mr-1"></span>
51-
Delete {taskIds.length} items
51+
{t("history:deleteItems", { count: taskIds.length })}
5252
</Button>
5353
</AlertDialogAction>
5454
</AlertDialogFooter>

webview-ui/src/components/history/HistoryView.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,15 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
7979
<VSCodeButton
8080
appearance={isSelectionMode ? "primary" : "secondary"}
8181
onClick={toggleSelectionMode}
82-
title={isSelectionMode ? "Exit Selection Mode" : "Enter Selection Mode"}>
82+
title={
83+
isSelectionMode
84+
? `${t("history:exitSelectionMode")}`
85+
: `${t("history:enterSelectionMode")}`
86+
}>
8387
<span
8488
className={`codicon ${isSelectionMode ? "codicon-check-all" : "codicon-checklist"}`}
8589
/>
86-
{isSelectionMode ? "Exit Selection" : "Selection Mode"}
90+
{isSelectionMode ? t("history:exitSelection") : t("history:selectionMode")}
8791
</VSCodeButton>
8892
<VSCodeButton onClick={onDone}>{t("history:done")}</VSCodeButton>
8993
</div>
@@ -146,10 +150,12 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
146150
onChange={(e) => toggleSelectAll((e.target as HTMLInputElement).checked)}
147151
/>
148152
<span className="ml-2 text-vscode-foreground">
149-
{selectedTaskIds.length === tasks.length ? "Deselect All" : "Select All"}
153+
{selectedTaskIds.length === tasks.length
154+
? t("history:deselectAll")
155+
: t("history:selectAll")}
150156
</span>
151157
<span className="ml-auto text-vscode-descriptionForeground text-xs">
152-
Selected {selectedTaskIds.length}/{tasks.length} items
158+
{t("history:selectedItems", { selected: selectedTaskIds.length, total: tasks.length })}
153159
</span>
154160
</div>
155161
)}
@@ -405,14 +411,14 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
405411
{isSelectionMode && selectedTaskIds.length > 0 && (
406412
<div className="fixed bottom-0 left-0 right-0 bg-vscode-editor-background border-t border-vscode-panel-border p-2 flex justify-between items-center">
407413
<div className="text-vscode-foreground">
408-
Selected <span className="font-bold">{selectedTaskIds.length}</span> items
414+
{t("history:selectedItems", { selected: selectedTaskIds.length, total: tasks.length })}
409415
</div>
410416
<div className="flex gap-2">
411417
<VSCodeButton appearance="secondary" onClick={() => setSelectedTaskIds([])}>
412-
Clear Selection
418+
{t("history:clearSelection")}
413419
</VSCodeButton>
414420
<VSCodeButton appearance="primary" onClick={handleBatchDelete}>
415-
Delete Selected
421+
{t("history:deleteSelected")}
416422
</VSCodeButton>
417423
</div>
418424
</div>

webview-ui/src/i18n/__mocks__/TranslationContext.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ export const useAppTranslation = () => {
55
return {
66
t: (key: string, options?: Record<string, any>) => {
77
const translations: Record<string, string> = {
8+
// Common translations
9+
"common:cancel": "Cancel",
810
// History translations
911
"history:recentTasks": "Recent Tasks",
1012
"history:viewAll": "View All",
1113
"history:history": "History",
14+
"history:exitSelectionMode": "Exit Selection Mode",
15+
"history:enterSelectionMode": "Enter Selection Mode",
1216
"history:done": "Done",
1317
"history:searchPlaceholder": "Fuzzy search history...",
1418
"history:newest": "Newest",
@@ -26,6 +30,19 @@ export const useAppTranslation = () => {
2630
"history:deleteTaskMessage": "Are you sure you want to delete this task? This action cannot be undone.",
2731
"history:cancel": "Cancel",
2832
"history:delete": "Delete",
33+
"history:exitSelection": "Exit Selection",
34+
"history:selectionMode": "Selection Mode",
35+
"history:deselectAll": "Deselect All",
36+
"history:selectAll": "Select All",
37+
"history:selectedItems": "Selected {selected}/{total} items",
38+
"history:clearSelection": "Clear Selection",
39+
"history:deleteSelected": "Delete Selected",
40+
"history:deleteTasks": "Delete Tasks",
41+
"history:confirmDeleteTasks":
42+
"Are you sure you want to delete {count} tasks? This action cannot be undone.",
43+
"history:deleteTasksWarning":
44+
"Deleted tasks cannot be recovered. Please make sure you want to proceed.",
45+
"history:deleteItems": "Delete {count} Items",
2946
}
3047

3148
// Handle interpolation

webview-ui/src/i18n/locales/ar/common.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"changeSettings": "يمكنك دائمًا تغيير هذا في أسفل الإعدادات",
55
"settings": "الإعدادات",
66
"allow": "السماح",
7-
"deny": "رفض"
7+
"deny": "رفض",
8+
"cancel": "إلغاء"
89
}

webview-ui/src/i18n/locales/ar/history.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"cache": "التخزين المؤقت: +{{writes}} → {{reads}}",
66
"apiCost": "تكلفة API: ${{cost}}",
77
"history": "السجل",
8+
"exitSelectionMode": "الخروج من وضع التحديد",
9+
"enterSelectionMode": "الدخول إلى وضع التحديد",
810
"done": "تم",
911
"searchPlaceholder": "البحث في السجل...",
1012
"newest": "الأحدث",
@@ -21,5 +23,16 @@
2123
"deleteTask": "حذف المهمة",
2224
"deleteTaskMessage": "هل أنت متأكد من حذف هذه المهمة؟ لا يمكن التراجع عن هذا الإجراء.",
2325
"cancel": "إلغاء",
24-
"delete": "حذف"
26+
"delete": "حذف",
27+
"exitSelection": "الخروج من التحديد",
28+
"selectionMode": "وضع التحديد",
29+
"deselectAll": "إلغاء تحديد الكل",
30+
"selectAll": "تحديد الكل",
31+
"selectedItems": "تم تحديد {{selected}}/{{total}} عنصر",
32+
"clearSelection": "مسح التحديد",
33+
"deleteSelected": "حذف المحدد",
34+
"deleteTasks": "حذف المهام",
35+
"confirmDeleteTasks": "هل أنت متأكد من حذف {{count}} مهمة؟",
36+
"deleteTasksWarning": "لا يمكن استعادة المهام المحذوفة. يرجى التأكد من المتابعة.",
37+
"deleteItems": "حذف {{count}} عنصر"
2538
}

webview-ui/src/i18n/locales/ca/common.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"changeSettings": "Sempre pots canviar això a la part inferior de la configuració",
55
"settings": "configuració",
66
"allow": "Permetre",
7-
"deny": "Denegar"
7+
"deny": "Denegar",
8+
"cancel": "Cancel·lar"
89
}

webview-ui/src/i18n/locales/ca/history.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"cache": "Cau: +{{writes}} → {{reads}}",
66
"apiCost": "Cost d'API: ${{cost}}",
77
"history": "Historial",
8+
"exitSelectionMode": "Sortir del mode de selecció",
9+
"enterSelectionMode": "Entrar en mode de selecció",
810
"done": "Fet",
911
"searchPlaceholder": "Cerca a l'historial...",
1012
"newest": "Més recents",
@@ -21,5 +23,16 @@
2123
"deleteTask": "Eliminar tasca",
2224
"deleteTaskMessage": "Estàs segur que vols eliminar aquesta tasca? Aquesta acció no es pot desfer.",
2325
"cancel": "Cancel·lar",
24-
"delete": "Eliminar"
26+
"delete": "Eliminar",
27+
"exitSelection": "Sortir de la selecció",
28+
"selectionMode": "Mode de selecció",
29+
"deselectAll": "Desseleccionar tot",
30+
"selectAll": "Seleccionar tot",
31+
"selectedItems": "{{selected}}/{{total}} elements seleccionats",
32+
"clearSelection": "Netejar selecció",
33+
"deleteSelected": "Eliminar seleccionats",
34+
"deleteTasks": "Eliminar tasques",
35+
"confirmDeleteTasks": "Estàs segur que vols eliminar {{count}} tasques?",
36+
"deleteTasksWarning": "Les tasques eliminades no es poden recuperar. Si us plau, assegura't que vols continuar.",
37+
"deleteItems": "Eliminar {{count}} elements"
2538
}

webview-ui/src/i18n/locales/cs/common.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"changeSettings": "Toto nastavení můžete vždy změnit v dolní části nastavení",
55
"settings": "nastavení",
66
"allow": "Povolit",
7-
"deny": "Zakázat"
7+
"deny": "Zakázat",
8+
"cancel": "Zrušit"
89
}

webview-ui/src/i18n/locales/cs/history.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"cache": "Mezipaměť: +{{writes}} → {{reads}}",
66
"apiCost": "Náklady API: ${{cost}}",
77
"history": "Historie",
8+
"exitSelectionMode": "Ukončit režim výběru",
9+
"enterSelectionMode": "Spustit režim výběru",
810
"done": "Hotovo",
911
"searchPlaceholder": "Vyhledat v historii...",
1012
"newest": "Nejnovější",
@@ -21,5 +23,16 @@
2123
"deleteTask": "Smazat úkol",
2224
"deleteTaskMessage": "Opravdu chcete smazat tento úkol? Tuto akci nelze vrátit zpět.",
2325
"cancel": "Zrušit",
24-
"delete": "Smazat"
26+
"delete": "Smazat",
27+
"exitSelection": "Ukončit výběr",
28+
"selectionMode": "Režim výběru",
29+
"deselectAll": "Zrušit výběr všech",
30+
"selectAll": "Vybrat vše",
31+
"selectedItems": "Vybráno {{selected}}/{{total}} položek",
32+
"clearSelection": "Vyčistit výběr",
33+
"deleteSelected": "Smazat vybrané",
34+
"deleteTasks": "Smazat úkoly",
35+
"confirmDeleteTasks": "Opravdu chcete smazat {{count}} úkolů?",
36+
"deleteTasksWarning": "Smazané úkoly nelze obnovit. Prosím, ujistěte se, že chcete pokračovat.",
37+
"deleteItems": "Smazat {{count}} položek"
2538
}

webview-ui/src/i18n/locales/de/common.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"changeSettings": "Sie können dies jederzeit unten in den Einstellungen ändern",
55
"settings": "Einstellungen",
66
"allow": "Erlauben",
7-
"deny": "Ablehnen"
7+
"deny": "Ablehnen",
8+
"cancel": "Abbrechen"
89
}

0 commit comments

Comments
 (0)