Skip to content

Commit 2c92fa2

Browse files
authored
国际化补充 (#426)
* 补充国际化字段 * 支持算子筛选国际化 * 支持算子筛选国际化
1 parent f95426a commit 2c92fa2

20 files changed

Lines changed: 310 additions & 101 deletions

File tree

frontend/src/i18n/locales/en/common.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,10 @@
599599
}
600600
},
601601
"common": {
602+
"yes": "Yes",
603+
"no": "No",
604+
"cancel": "Cancel",
605+
"refresh": "Refresh",
602606
"settings": {
603607
"title": "Settings"
604608
},
@@ -1373,6 +1377,8 @@
13731377
"descriptionPlaceholder": "Describe the purpose",
13741378
"srcDataset": "Source Dataset",
13751379
"srcDatasetPlaceholder": "Select source dataset",
1380+
"destDatasetName": "Target Dataset Name",
1381+
"destDatasetNamePlaceholder": "Enter or select target dataset name",
13761382
"destDatasetType": "Target Dataset Type",
13771383
"useSourceDataset": "Use Source Dataset",
13781384
"useSourceDatasetHint": "Output will be replaced in source dataset",
@@ -1871,6 +1877,52 @@
18711877
"latestVersion": "Latest Version",
18721878
"noReleases": "No version release information",
18731879
"initialize": "Click to initialize"
1880+
},
1881+
"examples": {
1882+
"copyCode": "Copy Code"
1883+
},
1884+
"service": {
1885+
"notSupported": "Deployment not supported",
1886+
"confirmUninstall": "Confirm uninstall service?",
1887+
"uninstallConfirm": "The service will stop running after uninstallation. Continue?",
1888+
"uninstall": "Uninstall",
1889+
"status": {
1890+
"running": "Running",
1891+
"failed": "Failed",
1892+
"standby": "Standby",
1893+
"stopped": "Stopped"
1894+
},
1895+
"notDeployed": "Not deployed",
1896+
"clickToDeploy": "Click to deploy",
1897+
"deploy": "Deploy",
1898+
"notSupportedHint": "This operator does not support deployment",
1899+
"deploymentInfo": "Deployment Info",
1900+
"deployedAt": "Deployed At",
1901+
"version": "Version",
1902+
"replicas": "Replicas",
1903+
"uninstallService": "Uninstall Service",
1904+
"podMonitor": "Pod Monitor",
1905+
"noPods": "No Pods",
1906+
"createdAt": "Created At",
1907+
"cpuUsage": "CPU Usage",
1908+
"memoryUsage": "Memory Usage",
1909+
"restartCount": "Restart Count",
1910+
"viewLogs": "View Logs",
1911+
"deploying": "Deploying",
1912+
"logs": "Logs",
1913+
"copyLogs": "Copy Logs",
1914+
"close": "Close"
1915+
},
1916+
"requirement": {
1917+
"systemRequirements": "System Requirements",
1918+
"cpuSpec": "CPU Spec",
1919+
"noLimit": "No Limit",
1920+
"memorySpec": "Memory Spec",
1921+
"storage": "Storage",
1922+
"gpuSupport": "GPU Support",
1923+
"npuSupport": "NPU Support",
1924+
"dependencies": "Dependencies",
1925+
"parseError": "Failed to parse data"
18741926
}
18751927
},
18761928
"create": {

frontend/src/i18n/locales/zh/common.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,10 @@
599599
}
600600
},
601601
"common": {
602+
"yes": "",
603+
"no": "",
604+
"cancel": "取消",
605+
"refresh": "刷新",
602606
"settings": {
603607
"title": "设置"
604608
},
@@ -1872,6 +1876,52 @@
18721876
"latestVersion": "最新版本",
18731877
"noReleases": "暂无版本发布信息",
18741878
"initialize": "点击初始化"
1879+
},
1880+
"examples": {
1881+
"copyCode": "复制代码"
1882+
},
1883+
"service": {
1884+
"notSupported": "暂不支持部署",
1885+
"confirmUninstall": "确认卸载服务?",
1886+
"uninstallConfirm": "卸载后服务将停止运行,是否继续?",
1887+
"uninstall": "卸载",
1888+
"status": {
1889+
"running": "运行中",
1890+
"failed": "失败",
1891+
"standby": "待机",
1892+
"stopped": "已停止"
1893+
},
1894+
"notDeployed": "未部署",
1895+
"clickToDeploy": "点击部署",
1896+
"deploy": "部署",
1897+
"notSupportedHint": "当前算子不支持部署功能",
1898+
"deploymentInfo": "部署信息",
1899+
"deployedAt": "部署时间",
1900+
"version": "版本",
1901+
"replicas": "副本数",
1902+
"uninstallService": "卸载服务",
1903+
"podMonitor": "Pod 监控",
1904+
"noPods": "暂无 Pod",
1905+
"createdAt": "创建时间",
1906+
"cpuUsage": "CPU 使用率",
1907+
"memoryUsage": "内存使用率",
1908+
"restartCount": "重启次数",
1909+
"viewLogs": "查看日志",
1910+
"deploying": "部署中",
1911+
"logs": "日志",
1912+
"copyLogs": "复制日志",
1913+
"close": "关闭"
1914+
},
1915+
"requirement": {
1916+
"systemRequirements": "系统规格",
1917+
"cpuSpec": "CPU 规格",
1918+
"noLimit": "无限制",
1919+
"memorySpec": "内存规格",
1920+
"storage": "存储",
1921+
"gpuSupport": "GPU 支持",
1922+
"npuSupport": "NPU 支持",
1923+
"dependencies": "依赖项",
1924+
"parseError": "数据解析失败"
18751925
}
18761926
},
18771927
"create": {

frontend/src/pages/DataCleansing/Create/components/ParamConfig.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
Switch,
1212
} from "antd";
1313
import { ConfigI, OperatorI } from "@/pages/OperatorMarket/operator.model";
14+
import { useTranslation } from "react-i18next";
1415

1516
interface ParamConfigProps {
1617
operator: OperatorI;
@@ -25,6 +26,7 @@ const ParamConfig: React.FC<ParamConfigProps> = ({
2526
param,
2627
onParamChange,
2728
}) => {
29+
const { t } = useTranslation();
2830
if (!param) return null;
2931
let defaultVal: any = operator.overrides?.[paramKey] ?? param.defaultVal;
3032
if (param.type === "range") {
@@ -53,7 +55,7 @@ const ParamConfig: React.FC<ParamConfigProps> = ({
5355
<Input
5456
value={value}
5557
onChange={(e) => updateValue(e.target.value)}
56-
placeholder={`请输入${param.name}`}
58+
placeholder={t("dataCleansing.paramConfig.enterValue", { name: param.name })}
5759
className="w-full"
5860
/>
5961
</Form.Item>
@@ -202,7 +204,7 @@ const ParamConfig: React.FC<ParamConfigProps> = ({
202204
<InputNumber
203205
value={value}
204206
onChange={(val) => updateValue(val)}
205-
placeholder={`请输入${param.name}`}
207+
placeholder={t("dataCleansing.paramConfig.enterValue", { name: param.name })}
206208
className="w-full"
207209
min={param.min}
208210
max={param.max}

frontend/src/pages/DataCleansing/Create/hooks/useOperatorOperations.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
queryOperatorsUsingPost,
88
} from "@/pages/OperatorMarket/operator.api";
99
import {useParams} from "react-router";
10+
import i18n from "@/i18n";
1011

1112
export function useOperatorOperations() {
1213
const { id = "" } = useParams();
@@ -97,6 +98,16 @@ export function useOperatorOperations() {
9798
initOperators();
9899
}, []);
99100

101+
useEffect(() => {
102+
const handleLanguageChange = () => {
103+
initOperators();
104+
};
105+
i18n.on('languageChanged', handleLanguageChange);
106+
return () => {
107+
i18n.off('languageChanged', handleLanguageChange);
108+
};
109+
}, [i18n]);
110+
100111
const toggleOperator = (operator: OperatorI) => {
101112
const exist = selectedOperators.find((op) => op.id === operator.id);
102113
if (exist) {

frontend/src/pages/DataCleansing/Detail/components/LogsTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default function LogsTable({ taskLog: initialLogs, fetchTaskLog, retryCou
8686
const url = window.URL.createObjectURL(blob);
8787
const a = document.createElement('a');
8888
a.href = url;
89-
a.download = `${taskName}_第${selectedLog}次运行.log`;
89+
a.download = `${taskName}_${t("dataCleansing.logTable.nthRun", { num: selectedLog })}.log`;
9090
document.body.appendChild(a);
9191
a.click();
9292
window.URL.revokeObjectURL(url);

frontend/src/pages/OperatorMarket/Create/OperatorPluginCreate.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ export default function OperatorPluginCreate() {
192192
</div>
193193
{uploadStep === "configure" && (
194194
<div className="flex justify-end gap-3 mt-8">
195-
<Button onClick={() => setUploadStep("upload")}>重新上传</Button>
195+
<Button onClick={() => setUploadStep("upload")}>{t("operatorMarket.create.actions.reupload")}</Button>
196196
<Button type="primary" onClick={handlePublish}>
197-
{id ? "更新" : "发布"}算子
197+
{id ? t("operatorMarket.create.actions.update") : t("operatorMarket.create.actions.publish")}
198198
</Button>
199199
</div>
200200
)}

frontend/src/pages/OperatorMarket/Detail/OperatorPluginDetail.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {Clock, GitBranch} from "lucide-react";
1010
import DetailHeader from "@/components/DetailHeader";
1111
import {Link, useNavigate, useParams} from "react-router";
1212
import { useTranslation } from "react-i18next";
13+
import i18n from "@/i18n";
1314
import Overview from "./components/Overview";
1415
import Requirement from "./components/Requirement";
1516
import Documentation from "./components/Documentation";
@@ -42,6 +43,16 @@ export default function OperatorPluginDetail() {
4243
fetchOperator();
4344
}, [id]);
4445

46+
useEffect(() => {
47+
const handleLanguageChange = () => {
48+
fetchOperator();
49+
};
50+
i18n.on('languageChanged', handleLanguageChange);
51+
return () => {
52+
i18n.off('languageChanged', handleLanguageChange);
53+
};
54+
}, [i18n, id]);
55+
4556
if (!operator) {
4657
return <div>Loading...</div>;
4758
}

frontend/src/pages/OperatorMarket/Detail/components/Examples.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { copyToClipboard } from "@/utils/unit";
22
import { Card, Button } from "antd";
33
import { Copy } from "lucide-react";
4+
import { useTranslation } from "react-i18next";
45

56
export default function Examples({ operator }) {
7+
const { t } = useTranslation();
8+
69
return (
710
<div className="flex flex-col gap-4">
811
{operator.examples.map((example, index) => (
@@ -13,7 +16,7 @@ export default function Examples({ operator }) {
1316
</h3>
1417
<Button size="small" onClick={() => copyToClipboard(example.code)}>
1518
<Copy className="w-4 h-4 mr-2" />
16-
复制代码
19+
{t("operatorMarket.detail.examples.copyCode")}
1720
</Button>
1821
</div>
1922
<div className="bg-gray-900 text-gray-100 p-4 rounded-lg overflow-x-auto">

0 commit comments

Comments
 (0)