diff --git a/app/[locale]/(main)/ClientComponents/ServerListClient.tsx b/app/[locale]/(main)/ClientComponents/ServerListClient.tsx index 00e3594..9226a7a 100644 --- a/app/[locale]/(main)/ClientComponents/ServerListClient.tsx +++ b/app/[locale]/(main)/ClientComponents/ServerListClient.tsx @@ -7,11 +7,12 @@ import useSWR from "swr"; import getEnv from "../../../../lib/env-entry"; import Switch from "@/components/Switch"; import { useState } from "react"; - -const defaultTag = "All"; +import { useTranslations } from "next-intl"; export default function ServerListClient() { - const [tag, setTag] = useState(defaultTag); + const t = useTranslations("ServerListClient"); + + const [tag, setTag] = useState(t("defaultTag")); const { data, error } = useSWR("/api/server", nezhaFetcher, { refreshInterval: Number(getEnv("NEXT_PUBLIC_NezhaFetchInterval")) || 2000, @@ -20,18 +21,13 @@ export default function ServerListClient() { return (

{error.message}

-

- Please check your environment variables and review the server console - logs for more details. -

+

{t("error_message")}

); if (!data) return null; const { result } = data; - - const sortedServers = result.sort((a, b) => { const displayIndexDiff = (b.display_index || 0) - (a.display_index || 0); if (displayIndexDiff !== 0) return displayIndexDiff; @@ -41,10 +37,10 @@ export default function ServerListClient() { const allTag = sortedServers.map((server) => server.tag).filter((tag) => tag); const uniqueTags = [...new Set(allTag)]; - uniqueTags.unshift(defaultTag); + uniqueTags.unshift(t("defaultTag")); const filteredServers = - tag === defaultTag + tag === t("defaultTag") ? sortedServers : sortedServers.filter((server) => server.tag === tag); diff --git a/bun.lockb b/bun.lockb index f164099..b7f3c40 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/Switch.tsx b/components/Switch.tsx index a8861c3..c51c121 100644 --- a/components/Switch.tsx +++ b/components/Switch.tsx @@ -14,7 +14,7 @@ export default function Switch({ setTag: (tag: string) => void; }) { return ( -
+
{allTag.map((tag) => (