Skip to content

Commit

Permalink
doc: improve translation
Browse files Browse the repository at this point in the history
  • Loading branch information
hamster1963 committed Oct 4, 2024
1 parent 58dc3e8 commit bd16fcc
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 25 deletions.
18 changes: 7 additions & 11 deletions app/[locale]/(main)/ClientComponents/ServerListClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>(defaultTag);
const t = useTranslations("ServerListClient");

const [tag, setTag] = useState<string>(t("defaultTag"));

const { data, error } = useSWR<ServerApi>("/api/server", nezhaFetcher, {
refreshInterval: Number(getEnv("NEXT_PUBLIC_NezhaFetchInterval")) || 2000,
Expand All @@ -20,18 +21,13 @@ export default function ServerListClient() {
return (
<div className="flex flex-col items-center justify-center">
<p className="text-sm font-medium opacity-40">{error.message}</p>
<p className="text-sm font-medium opacity-40">
Please check your environment variables and review the server console
logs for more details.
</p>
<p className="text-sm font-medium opacity-40">{t("error_message")}</p>
</div>
);
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;
Expand All @@ -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);

Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion components/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function Switch({
setTag: (tag: string) => void;
}) {
return (
<div className="z-50 flex flex-col overflow-x-scroll scrollbar-hidden rounded-[50px] items-start">
<div className="scrollbar-hidden z-50 flex flex-col items-start overflow-x-scroll rounded-[50px]">
<div className="flex items-center gap-1 rounded-[50px] bg-stone-100 p-[3px] dark:bg-stone-800">
{allTag.map((tag) => (
<div
Expand Down
4 changes: 4 additions & 0 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"p_2532-2599_Offlineservers": "Offline servers",
"p_3463-3530_Totalbandwidth": "Total bandwidth"
},
"ServerListClient": {
"error_message": "Please check your environment variables and review the server console",
"defaultTag": "All"
},
"ServerCard": {
"CPU": "CPU",
"Mem": "Mem",
Expand Down
4 changes: 4 additions & 0 deletions messages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"p_2532-2599_Offlineservers": "オフラインサーバー",
"p_3463-3530_Totalbandwidth": "総流量"
},
"ServerListClient": {
"error_message": "環境変数を確認し、サーバーコンソールを確認してください",
"defaultTag": "すべて"
},
"ServerCard": {
"CPU": "CPU",
"Mem": "Mem",
Expand Down
4 changes: 4 additions & 0 deletions messages/zh-t.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"p_2532-2599_Offlineservers": "離線伺服器",
"p_3463-3530_Totalbandwidth": "總流量"
},
"ServerListClient": {
"error_message": "請檢查您的環境變數並檢查伺服器控制台",
"defaultTag": "全部"
},
"ServerCard": {
"CPU": "CPU",
"Mem": "記憶體",
Expand Down
4 changes: 4 additions & 0 deletions messages/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"p_2532-2599_Offlineservers": "离线服务器",
"p_3463-3530_Totalbandwidth": "总流量"
},
"ServerListClient": {
"error_message": "请检查您的环境变量并检查服务器控制台",
"defaultTag": "全部"
},
"ServerCard": {
"CPU": "CPU",
"Mem": "内存",
Expand Down
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@
},
"dependencies": {
"@ducanh2912/next-pwa": "^10.2.9",
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-dropdown-menu": "^2.1.1",
"@radix-ui/react-navigation-menu": "^1.2.0",
"@radix-ui/react-popover": "^1.1.1",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-dropdown-menu": "^2.1.2",
"@radix-ui/react-navigation-menu": "^1.2.1",
"@radix-ui/react-popover": "^1.1.2",
"@radix-ui/react-progress": "^1.1.0",
"@radix-ui/react-separator": "^1.1.0",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.2",
"@radix-ui/react-tooltip": "^1.1.3",
"@types/luxon": "^3.4.2",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"caniuse-lite": "^1.0.30001664",
"caniuse-lite": "^1.0.30001667",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"country-flag-icons": "^1.5.13",
"eslint-plugin-simple-import-sort": "^12.1.1",
"flag-icons": "^7.2.3",
"framer-motion": "^11.9.0",
"framer-motion": "^11.11.1",
"lucide-react": "^0.414.0",
"luxon": "^3.5.0",
"next": "^14.2.13",
"next": "^14.2.14",
"next-intl": "^3.20.0",
"next-runtime-env": "^3.2.2",
"next-themes": "^0.3.0",
Expand All @@ -42,19 +42,19 @@
"react-wrap-balancer": "^1.1.1",
"sharp": "^0.33.5",
"swr": "^2.2.6-beta.4",
"tailwind-merge": "^2.5.2",
"tailwind-merge": "^2.5.3",
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"eslint-plugin-turbo": "^2.1.2",
"eslint-plugin-turbo": "^2.1.3",
"eslint-plugin-unused-imports": "^4.1.4",
"@next/bundle-analyzer": "^14.2.13",
"@next/bundle-analyzer": "^14.2.14",
"@types/node": "^22.7.4",
"@types/react": "^18.3.10",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.0",
"autoprefixer": "^10.4.20",
"eslint": "^9.11.1",
"eslint-config-next": "^14.2.13",
"eslint-config-next": "^14.2.14",
"postcss": "^8.4.47",
"prettier": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.8",
Expand Down

0 comments on commit bd16fcc

Please sign in to comment.