From e0e9faaa24ef83a345da598d82188f51a06d4a36 Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Thu, 12 Dec 2024 11:00:38 +0800 Subject: [PATCH] feat: ip info i18n --- app/(main)/ClientComponents/ServerIPInfo.tsx | 51 +++++++++++--------- messages/en.json | 9 ++++ messages/ja.json | 9 ++++ messages/zh-t.json | 9 ++++ messages/zh.json | 9 ++++ 5 files changed, 64 insertions(+), 23 deletions(-) diff --git a/app/(main)/ClientComponents/ServerIPInfo.tsx b/app/(main)/ClientComponents/ServerIPInfo.tsx index e26bf66..eb430d8 100644 --- a/app/(main)/ClientComponents/ServerIPInfo.tsx +++ b/app/(main)/ClientComponents/ServerIPInfo.tsx @@ -4,9 +4,12 @@ import { IPInfo } from "@/app/api/server-ip/route"; import { Loader } from "@/components/loading/Loader"; import { Card, CardContent } from "@/components/ui/card"; import { nezhaFetcher } from "@/lib/utils"; +import { useTranslations } from "next-intl"; import useSWRImmutable from "swr/immutable"; export default function ServerIPInfo({ server_id }: { server_id: number }) { + const t = useTranslations("IPInfo"); + const { data } = useSWRImmutable( `/api/server-ip?server_id=${server_id}`, nezhaFetcher, @@ -36,7 +39,7 @@ export default function ServerIPInfo({ server_id }: { server_id: number }) {
-

{"Origin ASN"}

+

{t("asn_number")}

AS{data.asn.autonomous_system_number}
@@ -47,7 +50,7 @@ export default function ServerIPInfo({ server_id }: { server_id: number }) {

- {"Registered Country"} + {t("registered_country")}

{data.city.registered_country?.names.en} @@ -55,24 +58,6 @@ export default function ServerIPInfo({ server_id }: { server_id: number }) {
- - -
-

{"Time Zone"}

-
{data.city.location?.time_zone}
-
-
-
- {data.city.postal && ( - - -
-

{"Postal"}

-
{data.city.postal?.code}
-
-
-
- )}
@@ -84,7 +69,7 @@ export default function ServerIPInfo({ server_id }: { server_id: number }) {
-

{"City"}

+

{t("city")}

{data.city.city?.names.en}
@@ -92,7 +77,7 @@ export default function ServerIPInfo({ server_id }: { server_id: number }) {
-

{"Longitude"}

+

{t("longitude")}

{data.city.location?.longitude}
@@ -100,11 +85,31 @@ export default function ServerIPInfo({ server_id }: { server_id: number }) {
-

{"Latitude"}

+

{t("latitude")}

{data.city.location?.latitude}
+ + +
+

{t("time_zone")}

+
{data.city.location?.time_zone}
+
+
+
+ {data.city.postal && ( + + +
+

+ {t("postal_code")} +

+
{data.city.postal?.code}
+
+
+
+ )}
); diff --git a/messages/en.json b/messages/en.json index 0825d9e..364733c 100644 --- a/messages/en.json +++ b/messages/en.json @@ -55,6 +55,15 @@ "avg_delay": "Latency", "chart_fetch_error_message": "Failed to fetch network data, please check if the server monitoring is enabled" }, + "IPInfo": { + "asn_number": "Origin ASN", + "registered_country": "Registered Country", + "time_zone": "Time Zone", + "postal_code": "Postal Code", + "city": "City", + "longitude": "Longitude", + "latitude": "Latitude" + }, "NetworkChart": { "ServerMonitorCount": "Services" }, diff --git a/messages/ja.json b/messages/ja.json index 998ca8b..56d966a 100644 --- a/messages/ja.json +++ b/messages/ja.json @@ -55,6 +55,15 @@ "avg_delay": "遅延", "chart_fetch_error_message": "ネットワークデータの取得に失敗しました。サーバーの監視が有効になっているかどうかを確認してください" }, + "IPInfo": { + "asn_number": "ASN", + "registered_country": "Registered Country", + "time_zone": "時刻", + "postal_code": "郵便番号", + "city": "都市", + "longitude": "経度", + "latitude": "緯度" + }, "NetworkChart": { "ServerMonitorCount": "サービス" }, diff --git a/messages/zh-t.json b/messages/zh-t.json index 49dca34..cd6713c 100644 --- a/messages/zh-t.json +++ b/messages/zh-t.json @@ -55,6 +55,15 @@ "avg_delay": "延遲", "chart_fetch_error_message": "獲取網絡數據失敗,請檢查是否開啟服務端監控" }, + "IPInfo": { + "asn_number": "ASN Number", + "registered_country": "注册地區", + "time_zone": "時區", + "postal_code": "郵遞區號", + "city": "城市", + "longitude": "經度", + "latitude": "緯度" + }, "NetworkChart": { "ServerMonitorCount": "個監測服務" }, diff --git a/messages/zh.json b/messages/zh.json index aa1ce1d..f7a3146 100644 --- a/messages/zh.json +++ b/messages/zh.json @@ -58,6 +58,15 @@ "NetworkChart": { "ServerMonitorCount": "个监控服务" }, + "IPInfo": { + "asn_number": "ASN 编号", + "registered_country": "注册地", + "time_zone": "时区", + "postal_code": "邮政编码", + "city": "城市", + "longitude": "经度", + "latitude": "纬度" + }, "ServerDetailClient": { "detail_fetch_error_message": "获取服务器详情失败,请检查您的环境变量并检查服务器控制台", "status": "状态",