i18n: complete internationalization for v3.8+ features

- Add health status translations (operational, degraded, failed, circuitOpen)
- Add proxy panel translations (serviceAddress, stats, stopped state)
- Add usage filter translations (appType, statusCode, searchPlaceholder)
- Add providerIcon click hints (clickToChange, clickToSelect)
- Add config load error translations for main.tsx
- Complete Japanese proxy section (failoverQueue, autoFailover)
- Fix date/time locale in usage charts and tables
- Use t() function in all hardcoded UI strings
This commit is contained in:
Jason
2025-12-20 21:38:37 +08:00
parent ec649e7718
commit 2fb3b5405a
17 changed files with 373 additions and 82 deletions
+8 -2
View File
@@ -5,6 +5,7 @@
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { invoke } from "@tauri-apps/api/core";
import { toast } from "sonner";
import { useTranslation } from "react-i18next";
import type { ProxyConfig } from "@/types/proxy";
/**
@@ -12,6 +13,7 @@ import type { ProxyConfig } from "@/types/proxy";
*/
export function useProxyConfig() {
const queryClient = useQueryClient();
const { t } = useTranslation();
// 查询配置
const { data: config, isLoading } = useQuery({
@@ -24,12 +26,16 @@ export function useProxyConfig() {
mutationFn: (newConfig: ProxyConfig) =>
invoke("update_proxy_config", { config: newConfig }),
onSuccess: () => {
toast.success("代理配置已保存", { closeButton: true });
toast.success(t("proxy.settings.toast.saved"), { closeButton: true });
queryClient.invalidateQueries({ queryKey: ["proxyConfig"] });
queryClient.invalidateQueries({ queryKey: ["proxyStatus"] });
},
onError: (error: Error) => {
toast.error(`保存失败: ${error.message}`);
toast.error(
t("proxy.settings.toast.saveFailed", {
error: error.message,
}),
);
},
});
+14 -5
View File
@@ -50,7 +50,8 @@ export function useProxyStatus() {
queryClient.invalidateQueries({ queryKey: ["proxyStatus"] });
},
onError: (error: Error) => {
const detail = extractErrorMessage(error) || "未知错误";
const detail =
extractErrorMessage(error) || t("common.unknown", { defaultValue: "未知错误" });
toast.error(
t("proxy.server.startFailed", {
defaultValue: `启动代理服务失败: ${detail}`,
@@ -75,7 +76,8 @@ export function useProxyStatus() {
queryClient.invalidateQueries({ queryKey: ["providerHealth"] });
},
onError: (error: Error) => {
const detail = extractErrorMessage(error) || "未知错误";
const detail =
extractErrorMessage(error) || t("common.unknown", { defaultValue: "未知错误" });
toast.error(
t("proxy.stopWithRestoreFailed", {
defaultValue: `停止失败: ${detail}`,
@@ -111,7 +113,8 @@ export function useProxyStatus() {
queryClient.invalidateQueries({ queryKey: ["proxyTakeoverStatus"] });
},
onError: (error: Error) => {
const detail = extractErrorMessage(error) || "未知错误";
const detail =
extractErrorMessage(error) || t("common.unknown", { defaultValue: "未知错误" });
toast.error(
t("proxy.takeover.failed", {
defaultValue: `操作失败: ${detail}`,
@@ -133,8 +136,14 @@ export function useProxyStatus() {
queryClient.invalidateQueries({ queryKey: ["proxyStatus"] });
},
onError: (error: Error) => {
const detail = extractErrorMessage(error) || "未知错误";
toast.error(`切换失败: ${detail}`);
const detail =
extractErrorMessage(error) || t("common.unknown", { defaultValue: "未知错误" });
toast.error(
t("proxy.switchFailed", {
error: detail,
defaultValue: `切换失败: ${detail}`,
}),
);
},
});