Skip to content

Commit 57590f3

Browse files
authored
feat: add internationalized translations of AI-related extensions (#632)
* feat: add internationalized translations of AI-related extensions * docs: update changelog * refactor: update
1 parent c18f9ea commit 57590f3

File tree

5 files changed

+89
-14
lines changed

5 files changed

+89
-14
lines changed

docs/content.en/docs/release-notes/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Information about release notes of Coco Server is provided here.
1818
- feat: calculator extension add description #623
1919
- feat: support right-click actions after text selection #624
2020
- feat: add ai overview minimum number of search results configuration #625
21+
- feat: add internationalized translations of AI-related extensions #632
2122

2223
### 🐛 Bug fix
2324

src/components/Settings/Extensions/components/Details/AiOverview/index.tsx

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useExtensionsStore } from "@/stores/extensionsStore";
22
import SharedAi from "../SharedAi";
33
import SettingsInput from "@/components/Settings/SettingsInput";
4+
import { useTranslation } from "react-i18next";
45

56
const AiOverview = () => {
67
const aiOverviewServer = useExtensionsStore((state) => {
@@ -33,23 +34,30 @@ const AiOverview = () => {
3334
const setAiOverviewMinQuantity = useExtensionsStore((state) => {
3435
return state.setAiOverviewMinQuantity;
3536
});
37+
const { t } = useTranslation();
3638

3739
const inputList = [
3840
{
39-
label: "Minimum Input Length(characters)",
41+
label: t(
42+
"settings.extensions.aiOverview.details.aiOverviewTrigger.label.minQuantity"
43+
),
44+
value: aiOverviewMinQuantity,
45+
onChange: setAiOverviewMinQuantity,
46+
},
47+
{
48+
label: t(
49+
"settings.extensions.aiOverview.details.aiOverviewTrigger.label.minCharLen"
50+
),
4051
value: aiOverviewCharLen,
4152
onChange: setAiOverviewCharLen,
4253
},
4354
{
44-
label: "Delay After Typing Stops(seconds)",
55+
label: t(
56+
"settings.extensions.aiOverview.details.aiOverviewTrigger.label.minDelay"
57+
),
4558
value: aiOverviewDelay,
4659
onChange: setAiOverviewDelay,
4760
},
48-
{
49-
label: "Minimum Number of Search Results",
50-
value: aiOverviewMinQuantity,
51-
onChange: setAiOverviewMinQuantity,
52-
},
5361
];
5462

5563
return (
@@ -65,11 +73,13 @@ const AiOverview = () => {
6573

6674
<>
6775
<div className="mt-6 text-[#333] dark:text-white/90">
68-
AI Overview Trigger
76+
{t("settings.extensions.aiOverview.details.aiOverviewTrigger.title")}
6977
</div>
7078

7179
<div className="pt-2 pb-4 text-[#999]">
72-
AI Overview will be triggered when both conditions are met.
80+
{t(
81+
"settings.extensions.aiOverview.details.aiOverviewTrigger.description"
82+
)}
7383
</div>
7484

7585
<div className="flex flex-col gap-2">

src/components/Settings/Extensions/components/Details/SharedAi/index.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import platformAdapter from "@/utils/platformAdapter";
66
import { useAsyncEffect, useMount } from "ahooks";
77
import { FC, useMemo, useState } from "react";
88
import { ExtensionId } from "../../..";
9+
import { useTranslation } from "react-i18next";
910

1011
interface SharedAiProps {
1112
id: ExtensionId;
@@ -22,6 +23,7 @@ const SharedAi: FC<SharedAiProps> = (props) => {
2223
const [assistantList, setAssistantList] = useState<any[]>([assistant]);
2324
const addError = useAppStore((state) => state.addError);
2425
const { fetchAssistant } = AssistantFetcher({});
26+
const { t } = useTranslation();
2527

2628
useMount(async () => {
2729
try {
@@ -72,7 +74,9 @@ const SharedAi: FC<SharedAiProps> = (props) => {
7274
const selectList = useMemo(() => {
7375
return [
7476
{
75-
label: "Coco Server",
77+
label: t(
78+
"settings.extensions.shardAi.details.linkedAssistant.label.cocoServer"
79+
),
7680
value: server?.id,
7781
icon: server?.provider?.icon,
7882
data: serverList,
@@ -83,7 +87,9 @@ const SharedAi: FC<SharedAiProps> = (props) => {
8387
},
8488
},
8589
{
86-
label: "AI Assistant",
90+
label: t(
91+
"settings.extensions.shardAi.details.linkedAssistant.label.aiAssistant"
92+
),
8793
value: assistant?.id,
8894
icon: assistant?.icon,
8995
data: assistantList,
@@ -98,19 +104,21 @@ const SharedAi: FC<SharedAiProps> = (props) => {
98104

99105
const renderDescription = () => {
100106
if (id === "QuickAIAccess") {
101-
return "Quick AI access allows you to start a conversation immediately from the search box using the tab key.";
107+
return t("settings.extensions.quickAiAccess.description");
102108
}
103109

104110
if (id === "AIOverview") {
105-
return "AI Summarize generates concise summaries based on your search results, helping you quickly grasp key information without reading every document.";
111+
return t("settings.extensions.aiOverview.description");
106112
}
107113
};
108114

109115
return (
110116
<>
111117
<div className="text-[#999]">{renderDescription()}</div>
112118

113-
<div className="mt-6 text-[#333] dark:text-white/90">LinkedAssistant</div>
119+
<div className="mt-6 text-[#333] dark:text-white/90">
120+
{t("settings.extensions.shardAi.details.linkedAssistant.title")}
121+
</div>
114122

115123
{selectList.map((item) => {
116124
const { label, value, icon, data, onChange } = item;

src/locales/en/translation.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,34 @@
233233
"calculator": {
234234
"title": "Calculator",
235235
"description": "A calculator you can quickly invoke in the search bar, supporting basic math operations."
236+
},
237+
"shardAi": {
238+
"details": {
239+
"linkedAssistant": {
240+
"title": "Linked Assistant",
241+
"label": {
242+
"cocoServer": "Coco Server",
243+
"aiAssistant": "AI Assistant"
244+
}
245+
}
246+
}
247+
},
248+
"quickAiAccess": {
249+
"description": "Quick AI access allows you to start a conversation immediately from the search box using the Tab key."
250+
},
251+
"aiOverview": {
252+
"description": "AI Overview generates concise summaries based on your search results, helping you quickly grasp key information without reading every document.",
253+
"details": {
254+
"aiOverviewTrigger": {
255+
"title": "AI Overview Trigger",
256+
"description": "AI Overview will be triggered only when all of the following conditions are met.(search results are sourced from Coco Server's result statistics)",
257+
"label": {
258+
"minCharLen": "Minimum Input Length(characters)",
259+
"minDelay": "Delay After Typing Stops(seconds)",
260+
"minQuantity": "Minimum Number of Search Results"
261+
}
262+
}
263+
}
236264
}
237265
}
238266
},

src/locales/zh/translation.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,34 @@
233233
"calculator": {
234234
"title": "计算器",
235235
"description": "在搜索框中快速调用的计算工具,支持基本数学运算。"
236+
},
237+
"shardAi": {
238+
"details": {
239+
"linkedAssistant": {
240+
"title": "关联助手",
241+
"label": {
242+
"cocoServer": "Coco Server",
243+
"aiAssistant": "AI 助手"
244+
}
245+
}
246+
}
247+
},
248+
"quickAiAccess": {
249+
"description": "通过 Tab 键,你可以立即从搜索框中启动与 AI 的对话。"
250+
},
251+
"aiOverview": {
252+
"description": "AI Overview 根据你的搜索结果生成简洁的摘要,帮助你快速掌握关键信息,无需逐一阅读每份文档。",
253+
"details": {
254+
"aiOverviewTrigger": {
255+
"title": "AI Overview 触发条件",
256+
"description": "仅当满足以下所有条件时,AI Overview 才会被触发。(搜索结果来源为 Coco Server 的结果统计)",
257+
"label": {
258+
"minCharLen": "最小输入长度(字符)",
259+
"minDelay": "输入停止延迟(秒)",
260+
"minQuantity": "最小搜索结果数"
261+
}
262+
}
263+
}
236264
}
237265
}
238266
},

0 commit comments

Comments
 (0)