fix(i18n): translate backend errors at UI boundaries
This commit is contained in:
1 parent
4422ac8e01
commit
2f44d36018
82 files changed
+1862
-335
No files matched your search
@@ -7,6 +7,7 @@ import { Loader2, CheckCircle2, XCircle, AlertCircle, FolderOpen, X } from "@luc
|
||||
import { useToast } from "@/composables/useToast";
|
||||
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
|
||||
import * as api from "@/lib/backend/api";
|
||||
import { translateBackendError } from "@/i18n/backend-errors";
|
||||
|
||||
const { t } = useI18n();
|
||||
const { toast } = useToast();
|
||||
@@ -30,6 +31,7 @@ const emit = defineEmits<{
|
||||
"update:open": [value: boolean];
|
||||
}>();
|
||||
|
||||
const translatedErrorMessage = computed(() => (props.errorMessage ? translateBackendError(t, props.errorMessage) : ""));
|
||||
const isActive = computed(() => props.status === "Running" || props.status === "Writing");
|
||||
const isFinished = computed(() => props.status === "Done" || props.status === "Error" || props.status === "Cancelled");
|
||||
const canRevealFile = computed(() => props.status === "Done" && !!props.filePath && isTauriRuntime());
|
||||
@@ -53,8 +55,7 @@ async function revealExportFile() {
|
||||
try {
|
||||
await api.revealPathInFileManager(props.filePath);
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
toast(t("exportProgress.openFolderFailed", { message }), 5000);
|
||||
toast(t("exportProgress.openFolderFailed", { message: translateBackendError(t, error) }), 5000);
|
||||
} finally {
|
||||
isRevealing.value = false;
|
||||
}
|
||||
@@ -106,7 +107,7 @@ async function revealExportFile() {
|
||||
</template>
|
||||
<template v-else-if="status === 'Error'">
|
||||
<XCircle class="h-4 w-4 text-destructive" />
|
||||
<span class="text-destructive">{{ errorMessage || t("exportProgress.error") }}</span>
|
||||
<span class="text-destructive">{{ translatedErrorMessage || t("exportProgress.error") }}</span>
|
||||
</template>
|
||||
<template v-else-if="status === 'Cancelled'">
|
||||
<AlertCircle class="h-4 w-4 text-yellow-500" />
|
||||
|
||||
@@ -5,6 +5,7 @@ import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Loader2, CheckCircle2, XCircle, AlertCircle, X, FileDown, DatabaseBackup, FileCode2, ArrowRightLeft, ChevronRight } from "@lucide/vue";
|
||||
import { formatDataTransferDuration, useExportTracker, type ExportTask } from "@/composables/useExportTracker";
|
||||
import { translateBackendError } from "@/i18n/backend-errors";
|
||||
|
||||
const { t } = useI18n();
|
||||
const { tasks, activeCount, hasActive, clearFinished, cancelTask, removeTask } = useExportTracker();
|
||||
@@ -185,8 +186,8 @@ function failureDetailCount(task: ExportTask) {
|
||||
|
||||
<div class="min-w-0 text-muted-foreground">
|
||||
<span class="break-words tabular-nums">{{ rowsText(task) }}</span>
|
||||
<span v-if="task.status === 'Error' && task.errorMessage" class="mt-1 block whitespace-normal break-words text-destructive" :title="task.errorMessage">
|
||||
{{ task.errorMessage }}
|
||||
<span v-if="task.status === 'Error' && task.errorMessage" class="mt-1 block whitespace-normal break-words text-destructive" :title="translateBackendError(t, task.errorMessage)">
|
||||
{{ translateBackendError(t, task.errorMessage) }}
|
||||
</span>
|
||||
<template v-if="task.kind === 'data-transfer' && failureDetailCount(task) > 0">
|
||||
<button class="mt-1.5 flex items-center gap-1 text-xs font-medium text-foreground hover:text-primary" :aria-expanded="failureDetailsExpanded(task.exportId)" @click="toggleFailureDetails(task.exportId)">
|
||||
|
||||
Reference in new issue
Block a user