fix(i18n): translate backend error messages in connection failure toasts

This commit is contained in:
t8y2
2026-05-14 11:00:52 +08:00
parent 43bd3a9ef8
commit e61efdea12
8 changed files with 67 additions and 10 deletions
+2 -1
View File
@@ -2,6 +2,7 @@
import { computed, nextTick, onMounted, ref } from "vue";
import { uuid } from "@/lib/utils";
import { useI18n } from "vue-i18n";
import { translateBackendError } from "@/i18n/backend-errors";
import {
ArrowUp,
ArrowRightLeft,
@@ -152,7 +153,7 @@ async function changeConnection(connectionId: string) {
queryStore.updateDatabase(tab.id, database);
}
} catch (e: any) {
toast(t("connection.connectFailed", { message: e?.message || String(e) }), 5000);
toast(t("connection.connectFailed", { message: translateBackendError(t, e?.message || String(e)) }), 5000);
}
}
+2 -1
View File
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { ref } from "vue";
import { useI18n } from "vue-i18n";
import { translateBackendError } from "@/i18n/backend-errors";
import { Upload, Download, RefreshCw } from "lucide-vue-next";
import { Button } from "@/components/ui/button";
import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
@@ -34,7 +35,7 @@ async function refreshTree() {
try {
await connectionStore.refreshAllTree();
} catch (e: any) {
toast(t("connection.connectFailed", { message: e?.message || String(e) }), 5000);
toast(t("connection.connectFailed", { message: translateBackendError(t, e?.message || String(e)) }), 5000);
}
}
+5 -4
View File
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { ref, computed, watch } from "vue";
import { useI18n } from "vue-i18n";
import { translateBackendError } from "@/i18n/backend-errors";
import {
Database,
Table,
@@ -304,7 +305,7 @@ async function toggle() {
}
} catch (e: any) {
if (!wasExpanded) node.isExpanded = false;
toast(t("connection.connectFailed", { message: e?.message || String(e) }), 5000);
toast(t("connection.connectFailed", { message: translateBackendError(t, e?.message || String(e)) }), 5000);
}
}
@@ -358,7 +359,7 @@ async function openObjectBrowser() {
await toggle();
}
} catch (e: any) {
toast(t("connection.connectFailed", { message: e?.message || String(e) }), 5000);
toast(t("connection.connectFailed", { message: translateBackendError(t, e?.message || String(e)) }), 5000);
}
}
@@ -460,7 +461,7 @@ async function newQuery() {
const options = await getDatabaseOptions(node.connectionId);
queryStore.createTab(node.connectionId, resolveDefaultDatabase(connection, options), undefined, "query");
} catch (e: any) {
toast(t("connection.connectFailed", { message: e?.message || String(e) }), 5000);
toast(t("connection.connectFailed", { message: translateBackendError(t, e?.message || String(e)) }), 5000);
}
}
@@ -488,7 +489,7 @@ async function refresh() {
try {
await connectionStore.refreshTreeNode(props.node);
} catch (e: any) {
toast(t("connection.connectFailed", { message: e?.message || String(e) }), 5000);
toast(t("connection.connectFailed", { message: translateBackendError(t, e?.message || String(e)) }), 5000);
}
}