From 4032ff62a2d0d9130b6f8d73de8e5318b5d3638b Mon Sep 17 00:00:00 2001
From: hamster1963 <1410514192@qq.com>
Date: Thu, 5 Dec 2024 09:24:54 +0800
Subject: [PATCH] fix: i18n
---
src/components/CycleTransferStatsClient.tsx | 9 ++++++---
src/components/ServerCardInline.tsx | 4 ++--
src/components/ServerDetailOverview.tsx | 3 ++-
src/components/ServiceTracker.tsx | 10 ++++++++--
src/components/ServiceTrackerClient.tsx | 8 +++++---
src/locales/en/translation.json | 14 ++++++++++++++
src/locales/zh-CN/translation.json | 14 ++++++++++++++
src/locales/zh-TW/translation.json | 14 ++++++++++++++
8 files changed, 65 insertions(+), 11 deletions(-)
diff --git a/src/components/CycleTransferStatsClient.tsx b/src/components/CycleTransferStatsClient.tsx
index 78e25a8..68f1760 100644
--- a/src/components/CycleTransferStatsClient.tsx
+++ b/src/components/CycleTransferStatsClient.tsx
@@ -3,6 +3,7 @@ import { cn } from "@/lib/utils";
import { formatBytes } from "@/lib/format";
import AnimatedCircularProgressBar from "./ui/animated-circular-progress-bar";
import { CircleStackIcon } from "@heroicons/react/24/outline";
+import { useTranslation } from "react-i18next";
interface CycleTransferStatsClientProps {
name: string;
@@ -21,6 +22,7 @@ interface CycleTransferStatsClientProps {
export const CycleTransferStatsClient: React.FC<
CycleTransferStatsClientProps
> = ({ name, from, to, max, serverStats, className }) => {
+ const { t } = useTranslation();
return (
- {(uptime / 86400).toFixed(0)} {"Days"}
+ {(uptime / 86400).toFixed(0)} {t("serverCard.days")}
-
{t("CPU")}
+
{"CPU"}
{cpu.toFixed(2)}%
diff --git a/src/components/ServerDetailOverview.tsx b/src/components/ServerDetailOverview.tsx
index 0dea33e..ecb3c33 100644
--- a/src/components/ServerDetailOverview.tsx
+++ b/src/components/ServerDetailOverview.tsx
@@ -96,7 +96,8 @@ export default function ServerDetailOverview({
{" "}
- {online ? (uptime / 86400).toFixed(0) : "N/A"} {"Days"}{" "}
+ {online ? (uptime / 86400).toFixed(0) : "N/A"}{" "}
+ {t("serverDetail.days")}
diff --git a/src/components/ServiceTracker.tsx b/src/components/ServiceTracker.tsx
index 72caaf3..1ca2883 100644
--- a/src/components/ServiceTracker.tsx
+++ b/src/components/ServiceTracker.tsx
@@ -5,8 +5,11 @@ import { fetchService } from "@/lib/nezha-api";
import { ServiceData } from "@/types/nezha-api";
import { CycleTransferStatsCard } from "./CycleTransferStats";
import { Loader } from "./loading/Loader";
+import { useTranslation } from "react-i18next";
+import { ExclamationTriangleIcon } from "@heroicons/react/20/solid";
export const ServiceTracker: React.FC = () => {
+ const { t } = useTranslation();
const { data: serviceData, isLoading } = useQuery({
queryKey: ["service"],
queryFn: () => fetchService(),
@@ -40,7 +43,7 @@ export const ServiceTracker: React.FC = () => {
return (
- Loading...
+ {t("serviceTracker.loading")}
);
}
@@ -50,7 +53,10 @@ export const ServiceTracker: React.FC = () => {
!serviceData?.data?.cycle_transfer_stats
) {
return (
-
No service data available
+
+
+ {t("serviceTracker.noService")}
+
);
}
diff --git a/src/components/ServiceTrackerClient.tsx b/src/components/ServiceTrackerClient.tsx
index a6f2cfd..0872e5d 100644
--- a/src/components/ServiceTrackerClient.tsx
+++ b/src/components/ServiceTrackerClient.tsx
@@ -1,6 +1,7 @@
import React from "react";
import { cn } from "@/lib/utils";
import { Separator } from "./ui/separator";
+import { useTranslation } from "react-i18next";
interface ServiceTrackerProps {
days: Array<{
@@ -20,6 +21,7 @@ export const ServiceTrackerClient: React.FC
= ({
uptime = 100,
avgDelay = 0,
}) => {
+ const { t } = useTranslation();
return (
= ({
- {uptime.toFixed(1)}% uptime
+ {uptime.toFixed(1)}% {t("serviceTracker.uptime")}
@@ -61,8 +63,8 @@ export const ServiceTrackerClient: React.FC