From beb75908926eb7ab044c852da3cf842e6facfecf Mon Sep 17 00:00:00 2001 From: JOYCEQL <1449239013@qq.com> Date: Mon, 6 Jan 2025 13:20:42 +0800 Subject: [PATCH] feat: dock setting i18n --- .../src/components/preview/PreviewDock.tsx | 30 +++++++++++++------ apps/fronted/src/i18n/locales/en.json | 19 ++++++++++++ apps/fronted/src/i18n/locales/zh.json | 19 ++++++++++++ 3 files changed, 59 insertions(+), 9 deletions(-) diff --git a/apps/fronted/src/components/preview/PreviewDock.tsx b/apps/fronted/src/components/preview/PreviewDock.tsx index 169a68b..ce9e9d1 100644 --- a/apps/fronted/src/components/preview/PreviewDock.tsx +++ b/apps/fronted/src/components/preview/PreviewDock.tsx @@ -21,6 +21,7 @@ import { GITHUB_REPO_URL } from "@/config"; import { cn } from "@/lib/utils"; import { useGrammarCheck } from "@/hooks/useGrammarCheck"; import { useAIConfigStore } from "@/store/useAIConfigStore"; +import { useTranslations } from "next-intl"; export type IconProps = React.HTMLAttributes; @@ -51,6 +52,7 @@ export const PreviewDock = ({ resumeContentRef, }: PreviewDockProps) => { const router = useRouter(); + const t = useTranslations("previewDock"); const { checkGrammar, isChecking } = useGrammarCheck(); const { doubaoApiKey, doubaoModelId } = useAIConfigStore(); const handleGrammarCheck = useCallback(async () => { @@ -59,12 +61,12 @@ export const PreviewDock = ({ if (!doubaoApiKey || !doubaoModelId) { toast.error( <> - 请先配置 ApiKey 和 模型Id + {t("grammarCheck.configurePrompt")} ); @@ -75,9 +77,9 @@ export const PreviewDock = ({ const text = resumeContentRef.current.innerText; await checkGrammar(text); } catch (error) { - toast.error("语法检查失败,请重试"); + toast.error(t("grammarCheck.errorToast")); } - }, [resumeContentRef, doubaoApiKey, doubaoModelId]); + }, [resumeContentRef, doubaoApiKey, doubaoModelId, t]); const handleGoGitHub = () => { window.open(GITHUB_REPO_URL, "_blank"); @@ -101,7 +103,7 @@ export const PreviewDock = ({ -

切换模版

+

{t("switchTemplate")}

@@ -123,7 +125,11 @@ export const PreviewDock = ({ -

{isChecking ? "检查中..." : "AI语法纠错"}

+

+ {isChecking + ? t("grammarCheck.checking") + : t("grammarCheck.idle")} +

@@ -149,7 +155,11 @@ export const PreviewDock = ({ -

{sidePanelCollapsed ? "展开侧边栏" : "收起侧边栏"}

+

+ {sidePanelCollapsed + ? t("sidePanel.expand") + : t("sidePanel.collapse")} +

@@ -173,7 +183,9 @@ export const PreviewDock = ({ - {editPanelCollapsed ? "展开编辑面板" : "收起编辑面板"} + {editPanelCollapsed + ? t("editPanel.expand") + : t("editPanel.collapse")} @@ -193,7 +205,7 @@ export const PreviewDock = ({ -

GitHub

+

{t("github")}

diff --git a/apps/fronted/src/i18n/locales/en.json b/apps/fronted/src/i18n/locales/en.json index 7d7c4d2..27b50a4 100644 --- a/apps/fronted/src/i18n/locales/en.json +++ b/apps/fronted/src/i18n/locales/en.json @@ -86,6 +86,25 @@ "error": "PDF export failed, please try again" } }, + "previewDock": { + "switchTemplate": "Switch Template", + "grammarCheck": { + "idle": "AI Grammar Check", + "checking": "Checking...", + "configurePrompt": "Please configure ApiKey and Model Id first", + "configureButton": "Configure", + "errorToast": "Grammar check failed, please try again" + }, + "sidePanel": { + "expand": "Expand Sidebar", + "collapse": "Collapse Sidebar" + }, + "editPanel": { + "expand": "Expand Edit Panel", + "collapse": "Collapse Edit Panel" + }, + "github": "GitHub" + }, "workbench": { "sidePanel": { "layout": { diff --git a/apps/fronted/src/i18n/locales/zh.json b/apps/fronted/src/i18n/locales/zh.json index 30fbd3b..e7fa2c5 100644 --- a/apps/fronted/src/i18n/locales/zh.json +++ b/apps/fronted/src/i18n/locales/zh.json @@ -298,5 +298,24 @@ "hide": "隐藏" } } + }, + "previewDock": { + "switchTemplate": "切换模版", + "grammarCheck": { + "idle": "AI语法纠错", + "checking": "检查中...", + "configurePrompt": "请先配置 ApiKey 和 模型Id", + "configureButton": "去配置", + "errorToast": "语法检查失败,请重试" + }, + "sidePanel": { + "expand": "展开侧边栏", + "collapse": "收起侧边栏" + }, + "editPanel": { + "expand": "展开编辑面板", + "collapse": "收起编辑面板" + }, + "github": "GitHub" } }