feat(I18n): Add multiple languages ​​(zh-CN/zh-TW/en/it) (#8)

This commit is contained in:
GuGuGu
2024-11-29 20:47:09 +08:00
committed by GitHub
parent 7759c3e9ad
commit 24286a7449
44 changed files with 1138 additions and 366 deletions
+11 -7
View File
@@ -19,7 +19,10 @@ import { deleteServerGroups } from "@/api/server-group";
import { GroupTab } from "@/components/group-tab";
import { ServerGroupCard } from "@/components/server-group";
import { useTranslation } from "react-i18next";
export default function ServerGroupPage() {
const { t } = useTranslation();
const { data, mutate, error, isLoading } = useSWR<ModelServerGroupResponseItem[]>(
"/api/v1/server-group",
swrFetcher
@@ -27,9 +30,10 @@ export default function ServerGroupPage() {
useEffect(() => {
if (error)
toast("Error", {
description: `Error fetching resource: ${error.message}.`,
toast(t("Error"), {
description: t("Results.ErrorFetchingResource", { error: error.message }),
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [error]);
const columns: ColumnDef<ModelServerGroupResponseItem>[] = [
@@ -61,7 +65,7 @@ export default function ServerGroupPage() {
accessorFn: (row) => row.group.id,
},
{
header: "Name",
header: t("Name"),
accessorKey: "name",
accessorFn: (row) => row.group.name,
cell: ({ row }) => {
@@ -70,13 +74,13 @@ export default function ServerGroupPage() {
},
},
{
header: "Servers (ID)",
header: t("Server")+"(ID)",
accessorKey: "servers",
accessorFn: (row) => row.servers,
},
{
id: "actions",
header: "Actions",
header: t("Actions"),
cell: ({ row }) => {
const s = row.original;
return (
@@ -142,7 +146,7 @@ export default function ServerGroupPage() {
{isLoading ? (
<TableRow>
<TableCell colSpan={columns.length} className="h-24 text-center">
Loading ...
{t("Loading")}...
</TableCell>
</TableRow>
) : table.getRowModel().rows?.length ? (
@@ -158,7 +162,7 @@ export default function ServerGroupPage() {
) : (
<TableRow>
<TableCell colSpan={columns.length} className="h-24 text-center">
No results.
{t("NoResults")}
</TableCell>
</TableRow>
)}