From d249891e4443da83dd804d77af934eed07d02ffb Mon Sep 17 00:00:00 2001 From: sw3205933776 <3205933776@qq.com> Date: Fri, 5 Sep 2025 11:55:07 +0800 Subject: [PATCH] Split translation files by module --- src/components/ChatBox/BottomInput.tsx | 2 +- src/components/ChatBox/index.tsx | 4 +-- src/components/HistorySidebar/SearchInput.tsx | 2 +- src/components/HistorySidebar/index.tsx | 24 ++++++------- .../InstallStep/InstallDependencies.tsx | 4 +-- src/components/SearchHistoryDialog.tsx | 8 ++--- src/components/TopBar/index.tsx | 4 +-- src/components/WorkFlow/index.tsx | 2 +- src/i18n/locales/en-US.json | 20 ----------- src/i18n/locales/en/chat.json | 5 +++ src/i18n/locales/en/general.json | 12 +++++++ src/i18n/locales/en/index.ts | 12 +++++++ src/i18n/locales/en/layout.json | 5 +++ src/i18n/locales/en/taskHub.json | 14 ++++++++ src/i18n/locales/en/workforce.json | 3 ++ src/i18n/locales/index.ts | 4 +-- src/i18n/locales/zh-cn/chat.json | 5 +++ src/i18n/locales/zh-cn/general.json | 12 +++++++ src/i18n/locales/zh-cn/index.ts | 12 +++++++ src/i18n/locales/zh-cn/layout.json | 5 +++ .../{zh-CN.json => zh-cn/taskHub.json} | 12 ++----- src/i18n/locales/zh-cn/workforce.json | 3 ++ src/pages/History.tsx | 28 +++++++-------- src/pages/Setting/General.tsx | 36 +++++++++++-------- 24 files changed, 153 insertions(+), 85 deletions(-) delete mode 100644 src/i18n/locales/en-US.json create mode 100644 src/i18n/locales/en/chat.json create mode 100644 src/i18n/locales/en/general.json create mode 100644 src/i18n/locales/en/index.ts create mode 100644 src/i18n/locales/en/layout.json create mode 100644 src/i18n/locales/en/taskHub.json create mode 100644 src/i18n/locales/en/workforce.json create mode 100644 src/i18n/locales/zh-cn/chat.json create mode 100644 src/i18n/locales/zh-cn/general.json create mode 100644 src/i18n/locales/zh-cn/index.ts create mode 100644 src/i18n/locales/zh-cn/layout.json rename src/i18n/locales/{zh-CN.json => zh-cn/taskHub.json} (51%) create mode 100644 src/i18n/locales/zh-cn/workforce.json diff --git a/src/components/ChatBox/BottomInput.tsx b/src/components/ChatBox/BottomInput.tsx index 34327f11e..d276dab8b 100644 --- a/src/components/ChatBox/BottomInput.tsx +++ b/src/components/ChatBox/BottomInput.tsx @@ -324,7 +324,7 @@ export const BottomInput = ({ fontFamily: "Inter", }} rows={1} - placeholder={t("ask-placeholder")} + placeholder={t("chat.ask-placeholder")} onInput={(e) => { const el = e.currentTarget; el.style.height = "auto"; diff --git a/src/components/ChatBox/index.tsx b/src/components/ChatBox/index.tsx index 006eb1fdd..c6724da19 100644 --- a/src/components/ChatBox/index.tsx +++ b/src/components/ChatBox/index.tsx @@ -520,10 +520,10 @@ export default function ChatBox(): JSX.Element {
- {t("welcome-to-eigent")} + {t("chat.welcome-to-eigent")}
- {t("how-can-i-help-you")} + {t("chat.how-can-i-help-you")}
diff --git a/src/components/HistorySidebar/SearchInput.tsx b/src/components/HistorySidebar/SearchInput.tsx index 386f50304..e0b68bf40 100644 --- a/src/components/HistorySidebar/SearchInput.tsx +++ b/src/components/HistorySidebar/SearchInput.tsx @@ -28,7 +28,7 @@ export default function SearchInput({ value, onChange }: SearchInputProps) { {!value && !isFocused && ( - {t("search")} + {t("task-hub.search")} )} diff --git a/src/components/HistorySidebar/index.tsx b/src/components/HistorySidebar/index.tsx index 5fde933c8..1f8917312 100644 --- a/src/components/HistorySidebar/index.tsx +++ b/src/components/HistorySidebar/index.tsx @@ -241,7 +241,7 @@ export default function HistorySidebar() { > - {t("task-hub")} + {t("task-hub.task-hub")}
{history_type === "table" ? ( @@ -299,7 +299,7 @@ export default function HistorySidebar() { />
- {task?.messages[0]?.content || t("new-project")} + {task?.messages[0]?.content || t("task-hub.new-project")}
{task?.messages[0]?.content || - t("new-project")} + t("task-hub.new-project")}

{task?.messages[0]?.content || - t("new-project")} + t("task-hub.new-project")}

@@ -421,7 +421,7 @@ export default function HistorySidebar() {
- {t("project-archives")} + {t("task-hub.project-archives")}
{task?.question.split("|")[1] || - t("new-project")} + t("task-hub.new-project")}
); @@ -514,7 +514,7 @@ export default function HistorySidebar() { {" "} - {task?.question.split("|")[0] || t("new-project")} + {task?.question.split("|")[0] || t("task-hub.new-project")}
{" "} - {task?.question.split("|")[0] || t("new-project")} + {task?.question.split("|")[0] || t("task-hub.new-project")}
@@ -558,7 +558,7 @@ export default function HistorySidebar() { }} > - {t("share")} + {t("task-hub.share")} @@ -576,7 +576,7 @@ export default function HistorySidebar() { size={16} className="text-icon-primary group-hover:text-icon-cuation" /> - {t("delete")} + {t("task-hub.delete")}
diff --git a/src/components/InstallStep/InstallDependencies.tsx b/src/components/InstallStep/InstallDependencies.tsx index 48ddc85b1..f5ddee631 100644 --- a/src/components/InstallStep/InstallDependencies.tsx +++ b/src/components/InstallStep/InstallDependencies.tsx @@ -211,10 +211,10 @@ export const InstallDependencies: React.FC<{ className="mr-2 no-drag leading-tight" > - {t("report-bug")} + {t("layout.report-bug")} diff --git a/src/components/SearchHistoryDialog.tsx b/src/components/SearchHistoryDialog.tsx index 8dd0ea31c..7808c73f7 100644 --- a/src/components/SearchHistoryDialog.tsx +++ b/src/components/SearchHistoryDialog.tsx @@ -73,15 +73,15 @@ export function SearchHistoryDialog() { onClick={() => setOpen(true)} > - {t("search")} + {t("task-hub.search")} - {t("search-dialog")} + {t("task-hub.search-dialog")} - + - {t("no-results")} + {t("task-hub.no-results")} {historyTasks.map((task) => ( - {t("report-bug")} + {t("layout.report-bug")} -
{t("table")}
+
{t("task-hub.table")}
-
{t("list")}
+
{t("task-hub.list")}
@@ -306,7 +306,7 @@ export default function Home() { />
- {task.summaryTask || t("new-project")} + {task.summaryTask || t("task-hub.new-project")}
- {task.summaryTask || t("new-project")} + {task.summaryTask || t("task-hub.new-project")} -

{task.summaryTask || t("new-project")}

+

{task.summaryTask || t("task-hub.new-project")}

@@ -532,11 +532,11 @@ export default function Home() {
-
{t("table")}
+
{t("task-hub.table")}
-
{t("list")}
+
{t("task-hub.list")}
@@ -577,7 +577,7 @@ export default function Home() {
- {task?.question || t("new-project")} + {task?.question || t("task-hub.new-project")}
@@ -609,7 +609,7 @@ export default function Home() { {" "} - {task?.question.split("|")[0] || t("new-project")} + {task?.question.split("|")[0] || t("task-hub.new-project")}
{" "} - {task?.question.split("|")[0] || t("new-project")} + {task?.question.split("|")[0] || t("task-hub.new-project")}
@@ -653,7 +653,7 @@ export default function Home() { }} > - {t("share")} + {t("task-hub.share")} @@ -671,7 +671,7 @@ export default function Home() { size={16} className="text-icon-primary group-hover:text-icon-cuation" /> - {t("delete")} + {t("task-hub.delete")} diff --git a/src/pages/Setting/General.tsx b/src/pages/Setting/General.tsx index f718f8497..e7ef2d847 100644 --- a/src/pages/Setting/General.tsx +++ b/src/pages/Setting/General.tsx @@ -11,7 +11,8 @@ import { proxyFetchPut, proxyFetchGet } from "@/api/http"; import { createRef, RefObject } from "react"; import { useEffect, useState } from "react"; import { useChatStore } from "@/store/chatStore"; -import {LocaleEnum, switchLanguage} from "@/i18n"; +import { LocaleEnum, switchLanguage } from "@/i18n"; +import { useTranslation } from "react-i18next"; import { Select, @@ -24,6 +25,7 @@ import { } from "@/components/ui/select"; export default function SettingGeneral() { + const { t } = useTranslation(); const authStore = useAuthStore(); const navigate = useNavigate(); const [isLoading, setIsLoading] = useState(false); @@ -39,12 +41,12 @@ export default function SettingGeneral() { const [themeList, setThemeList] = useState([ { img: light, - label: "Light", + label: "general.light", value: "light", }, { img: transparent, - label: "Transparent", + label: "general.transparent", value: "transparent", }, ]); @@ -91,12 +93,12 @@ export default function SettingGeneral() { setThemeList([ { img: light, - label: "Light", + label: "general.light", value: "light", }, { img: transparent, - label: "Transparent", + label: "general.transparent", value: "transparent", }, ]); @@ -104,7 +106,7 @@ export default function SettingGeneral() { setThemeList([ { img: light, - label: "Light", + label: "general.light", value: "light", }, ]); @@ -115,10 +117,12 @@ export default function SettingGeneral() {
- Account + {t("general.account")}
- You are currently signed in with {authStore.email} + {t("general.you-are-currently-signed-in-with", { + email: authStore.email, + })}
- Language + {t("general.language")}