From c09ff253605579144aecca5e5cf71e0172fbe24d Mon Sep 17 00:00:00 2001 From: JiPai Date: Sat, 9 Nov 2024 18:16:06 +0800 Subject: [PATCH] feat(i18n): add translation for server tab --- CONTRIBUTING.md | 2 +- .../servers/actions/show-dokploy-actions.tsx | 12 ++++-- .../servers/actions/show-storage-actions.tsx | 30 ++++++++++---- .../servers/actions/show-traefik-actions.tsx | 14 ++++--- .../dashboard/settings/web-domain.tsx | 38 +++++++++++++---- .../dashboard/settings/web-server.tsx | 10 ++++- .../pages/dashboard/settings/server.tsx | 4 ++ apps/dokploy/public/locales/en/settings.json | 41 +++++++++++++++++++ .../public/locales/zh-Hans/settings.json | 41 +++++++++++++++++++ 9 files changed, 163 insertions(+), 29 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 05256d57..07ad6022 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -235,7 +235,7 @@ export function generate(schema: Schema): Template { 5. Add the logo or image of the template to `public/templates/plausible.svg` -### Recomendations +### Recommendations - Use the same name of the folder as the id of the template. - The logo should be in the public folder. diff --git a/apps/dokploy/components/dashboard/settings/servers/actions/show-dokploy-actions.tsx b/apps/dokploy/components/dashboard/settings/servers/actions/show-dokploy-actions.tsx index 49f6772b..3e479073 100644 --- a/apps/dokploy/components/dashboard/settings/servers/actions/show-dokploy-actions.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/actions/show-dokploy-actions.tsx @@ -11,10 +11,12 @@ import { DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { api } from "@/utils/api"; +import { useTranslation } from "next-i18next"; import { toast } from "sonner"; import { ShowModalLogs } from "../../web-server/show-modal-logs"; export const ShowDokployActions = () => { + const { t } = useTranslation("settings"); const { mutateAsync: reloadServer, isLoading } = api.settings.reloadServer.useMutation(); @@ -22,11 +24,13 @@ export const ShowDokployActions = () => { - Actions + + {t("settings.server.webServer.actions")} + { }); }} > - Reload + {t("settings.server.webServer.reload")} - Watch logs + {t("settings.server.webServer.watchLogs")} diff --git a/apps/dokploy/components/dashboard/settings/servers/actions/show-storage-actions.tsx b/apps/dokploy/components/dashboard/settings/servers/actions/show-storage-actions.tsx index b3f9c334..7163332d 100644 --- a/apps/dokploy/components/dashboard/settings/servers/actions/show-storage-actions.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/actions/show-storage-actions.tsx @@ -11,12 +11,14 @@ import { DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { api } from "@/utils/api"; +import { useTranslation } from "next-i18next"; import { toast } from "sonner"; interface Props { serverId?: string; } export const ShowStorageActions = ({ serverId }: Props) => { + const { t } = useTranslation("settings"); const { mutateAsync: cleanAll, isLoading: cleanAllIsLoading } = api.settings.cleanAll.useMutation(); @@ -64,11 +66,13 @@ export const ShowStorageActions = ({ serverId }: Props) => { } variant="outline" > - Space + {t("settings.server.webServer.storage.label")} - Actions + + {t("settings.server.webServer.actions")} + { }); }} > - Clean unused images + + {t("settings.server.webServer.storage.cleanUnusedImages")} + { }); }} > - Clean unused volumes + + {t("settings.server.webServer.storage.cleanUnusedVolumes")} + { }); }} > - Clean stopped containers + + {t("settings.server.webServer.storage.cleanStoppedContainers")} + { }); }} > - Clean Docker Builder & System + + {t("settings.server.webServer.storage.cleanDockerBuilder")} + {!serverId && ( { }); }} > - Clean Monitoring + + {t("settings.server.webServer.storage.cleanMonitoring")} + )} @@ -168,7 +182,7 @@ export const ShowStorageActions = ({ serverId }: Props) => { }); }} > - Clean all + {t("settings.server.webServer.storage.cleanAll")} diff --git a/apps/dokploy/components/dashboard/settings/servers/actions/show-traefik-actions.tsx b/apps/dokploy/components/dashboard/settings/servers/actions/show-traefik-actions.tsx index a0ea3f5e..5488712c 100644 --- a/apps/dokploy/components/dashboard/settings/servers/actions/show-traefik-actions.tsx +++ b/apps/dokploy/components/dashboard/settings/servers/actions/show-traefik-actions.tsx @@ -23,6 +23,7 @@ import { api } from "@/utils/api"; import { toast } from "sonner"; import { cn } from "@/lib/utils"; +import { useTranslation } from "next-i18next"; import { EditTraefikEnv } from "../../web-server/edit-traefik-env"; import { ShowModalLogs } from "../../web-server/show-modal-logs"; @@ -30,6 +31,7 @@ interface Props { serverId?: string; } export const ShowTraefikActions = ({ serverId }: Props) => { + const { t } = useTranslation("settings"); const { mutateAsync: reloadTraefik, isLoading: reloadTraefikIsLoading } = api.settings.reloadTraefik.useMutation(); @@ -51,11 +53,13 @@ export const ShowTraefikActions = ({ serverId }: Props) => { isLoading={reloadTraefikIsLoading || toggleDashboardIsLoading} variant="outline" > - Traefik + {t("settings.server.webServer.traefik.label")} - Actions + + {t("settings.server.webServer.actions")} + { }); }} > - Reload + {t("settings.server.webServer.reload")} - Watch logs + {t("settings.server.webServer.watchLogs")} e.preventDefault()} className="w-full cursor-pointer space-x-3" > - Modify Env + {t("settings.server.webServer.traefik.modifyEnv")} diff --git a/apps/dokploy/components/dashboard/settings/web-domain.tsx b/apps/dokploy/components/dashboard/settings/web-domain.tsx index 354f1158..00f54904 100644 --- a/apps/dokploy/components/dashboard/settings/web-domain.tsx +++ b/apps/dokploy/components/dashboard/settings/web-domain.tsx @@ -24,6 +24,7 @@ import { } from "@/components/ui/select"; import { api } from "@/utils/api"; import { zodResolver } from "@hookform/resolvers/zod"; +import { useTranslation } from "next-i18next"; import { useEffect } from "react"; import { useForm } from "react-hook-form"; import { toast } from "sonner"; @@ -49,6 +50,7 @@ const addServerDomain = z type AddServerDomain = z.infer; export const WebDomain = () => { + const { t } = useTranslation("settings"); const { data: user, refetch } = api.admin.one.useQuery(); const { mutateAsync, isLoading } = api.settings.assignDomainServer.useMutation(); @@ -89,9 +91,11 @@ export const WebDomain = () => {
- Server Domain + + {t("settings.server.domain.title")} + - Add a domain to your server application. + {t("settings.server.domain.description")} @@ -106,7 +110,9 @@ export const WebDomain = () => { render={({ field }) => { return ( - Domain + + {t("settings.server.domain.form.domain")} + { render={({ field }) => { return ( - Letsencrypt Email + + {t("settings.server.domain.form.letsEncryptEmail")} + { render={({ field }) => { return ( - Certificate + + {t("settings.server.domain.form.certificate.label")} + @@ -169,7 +189,7 @@ export const WebDomain = () => { />
diff --git a/apps/dokploy/components/dashboard/settings/web-server.tsx b/apps/dokploy/components/dashboard/settings/web-server.tsx index 188b3db8..2ac88d9a 100644 --- a/apps/dokploy/components/dashboard/settings/web-server.tsx +++ b/apps/dokploy/components/dashboard/settings/web-server.tsx @@ -7,6 +7,7 @@ import { } from "@/components/ui/card"; import { cn } from "@/lib/utils"; import { api } from "@/utils/api"; +import { useTranslation } from "next-i18next"; import React from "react"; import { ShowDokployActions } from "./servers/actions/show-dokploy-actions"; import { ShowStorageActions } from "./servers/actions/show-storage-actions"; @@ -18,6 +19,7 @@ interface Props { className?: string; } export const WebServer = ({ className }: Props) => { + const { t } = useTranslation("settings"); const { data } = api.admin.one.useQuery(); const { data: dokployVersion } = api.settings.getDokployVersion.useQuery(); @@ -25,8 +27,12 @@ export const WebServer = ({ className }: Props) => { return ( - Web server settings - Reload or clean the web server. + + {t("settings.server.webServer.title")} + + + {t("settings.server.webServer.description")} +
diff --git a/apps/dokploy/pages/dashboard/settings/server.tsx b/apps/dokploy/pages/dashboard/settings/server.tsx index 4763114e..c714acd8 100644 --- a/apps/dokploy/pages/dashboard/settings/server.tsx +++ b/apps/dokploy/pages/dashboard/settings/server.tsx @@ -3,9 +3,11 @@ import { WebServer } from "@/components/dashboard/settings/web-server"; import { DashboardLayout } from "@/components/layouts/dashboard-layout"; import { SettingsLayout } from "@/components/layouts/settings-layout"; import { appRouter } from "@/server/api/root"; +import { getLocale } from "@/utils/i18n"; import { IS_CLOUD, validateRequest } from "@dokploy/server"; import { createServerSideHelpers } from "@trpc/react-query/server"; import type { GetServerSidePropsContext } from "next"; +import { serverSideTranslations } from "next-i18next/serverSideTranslations"; import React, { type ReactElement } from "react"; import superjson from "superjson"; @@ -31,6 +33,7 @@ export async function getServerSideProps( ctx: GetServerSidePropsContext<{ serviceId: string }>, ) { const { req, res } = ctx; + const locale = await getLocale(req.cookies); if (IS_CLOUD) { return { redirect: { @@ -73,6 +76,7 @@ export async function getServerSideProps( return { props: { trpcState: helpers.dehydrate(), + ...(await serverSideTranslations(locale, ["settings"])), }, }; } diff --git a/apps/dokploy/public/locales/en/settings.json b/apps/dokploy/public/locales/en/settings.json index c4f6f362..10557f43 100644 --- a/apps/dokploy/public/locales/en/settings.json +++ b/apps/dokploy/public/locales/en/settings.json @@ -3,6 +3,47 @@ "common": { "save": "Save" }, + "server": { + "domain": { + "title": "Server Domain", + "description": "Add a domain to your server application.", + "form": { + "domain": "Domain", + "letsEncryptEmail": "Let's Encrypt Email", + "certificate": { + "label": "Certificate", + "placeholder": "Select a certificate" + }, + "certificateOptions": { + "none": "None", + "letsencrypt": "Let's Encrypt (Default)" + } + } + }, + "webServer": { + "title": "Web Server", + "description": "Reload or clean the web server.", + "actions": "Actions", + "reload": "Reload", + "watchLogs": "Watch logs", + "server": { + "label": "Server" + }, + "traefik": { + "label": "Traefik", + "modifyEnv": "Modify Env" + }, + "storage": { + "label": "Space", + "cleanUnusedImages": "Clean unused images", + "cleanUnusedVolumes": "Clean unused volumes", + "cleanStoppedContainers": "Clean stopped containers", + "cleanDockerBuilder": "Clean Docker Builder & System", + "cleanMonitoring": "Clean Monitoring", + "cleanAll": "Clean all" + } + } + }, "profile": { "title": "Account", "description": "Change the details of your profile here.", diff --git a/apps/dokploy/public/locales/zh-Hans/settings.json b/apps/dokploy/public/locales/zh-Hans/settings.json index d426bab6..79267f78 100644 --- a/apps/dokploy/public/locales/zh-Hans/settings.json +++ b/apps/dokploy/public/locales/zh-Hans/settings.json @@ -3,6 +3,47 @@ "common": { "save": "保存" }, + "server": { + "domain": { + "title": "服务器域名", + "description": "添加一个域名到您的服务器。", + "form": { + "domain": "域名", + "letsEncryptEmail": "Let's Encrypt 邮箱", + "certificate": { + "label": "证书", + "placeholder": "选择一个证书" + }, + "certificateOptions": { + "none": "无", + "letsencrypt": "Let's Encrypt (默认)" + } + } + }, + "webServer": { + "title": "Web 服务器", + "description": "管理 Web 服务器。", + "actions": "操作", + "reload": "重新加载", + "watchLogs": "查看日志", + "server": { + "label": "服务器" + }, + "traefik": { + "label": "Traefik", + "modifyEnv": "修改环境变量" + }, + "storage": { + "label": "磁盘空间", + "cleanUnusedImages": "清理未使用的镜像", + "cleanUnusedVolumes": "清理未使用的卷", + "cleanStoppedContainers": "清理停止的容器", + "cleanDockerBuilder": "清理 Docker Builder 和系统缓存", + "cleanMonitoring": "Clean Monitoring", + "cleanAll": "清理所有" + } + } + }, "profile": { "title": "账户偏好", "description": "更改您的个人资料详情。",