chore: update locale in connection

This commit is contained in:
dongchengjie 2024-05-20 13:42:45 +08:00
parent 08e0d6a34a
commit fb38047769
6 changed files with 78 additions and 28 deletions

View File

@ -54,29 +54,32 @@ const InnerConnectionDetail = ({ data, onClose }: InnerProps) => {
: `${metadata.destinationIP}:${metadata.destinationPort}`; : `${metadata.destinationIP}:${metadata.destinationPort}`;
const information = [ const information = [
{ label: "Host", value: host }, { label: t("Host"), value: host },
{ label: "Download", value: parseTraffic(data.download).join(" ") }, { label: t("Downloaded"), value: parseTraffic(data.download).join(" ") },
{ label: "Upload", value: parseTraffic(data.upload).join(" ") }, { label: t("Uploaded"), value: parseTraffic(data.upload).join(" ") },
{ {
label: "DL Speed", label: t("DL Speed"),
value: parseTraffic(data.curDownload ?? -1).join(" ") + "/s", value: parseTraffic(data.curDownload ?? -1).join(" ") + "/s",
}, },
{ {
label: "UL Speed", label: t("UL Speed"),
value: parseTraffic(data.curUpload ?? -1).join(" ") + "/s", value: parseTraffic(data.curUpload ?? -1).join(" ") + "/s",
}, },
{ label: "Chains", value: chains }, { label: t("Chains"), value: chains },
{ label: "Rule", value: rule }, { label: t("Rule"), value: rule },
{ {
label: "Process", label: t("Process"),
value: `${metadata.process}${ value: `${metadata.process}${
metadata.processPath ? `(${metadata.processPath})` : "" metadata.processPath ? `(${metadata.processPath})` : ""
}`, }`,
}, },
{ label: "Time", value: dayjs(data.start).fromNow() }, { label: t("Time"), value: dayjs(data.start).fromNow() },
{ label: "Source", value: `${metadata.sourceIP}:${metadata.sourcePort}` }, {
{ label: "Destination IP", value: metadata.destinationIP }, label: t("Source"),
{ label: "Type", value: `${metadata.type}(${metadata.network})` }, value: `${metadata.sourceIP}:${metadata.sourcePort}`,
},
{ label: t("Destination IP"), value: metadata.destinationIP },
{ label: t("Type"), value: `${metadata.type}(${metadata.network})` },
]; ];
const onDelete = useLockFn(async () => deleteConnection(data.id)); const onDelete = useLockFn(async () => deleteConnection(data.id));
@ -92,13 +95,13 @@ const InnerConnectionDetail = ({ data, onClose }: InnerProps) => {
<Box sx={{ textAlign: "right" }}> <Box sx={{ textAlign: "right" }}>
<Button <Button
variant="contained" variant="contained"
title="Close Connection" title={t("Close Connection")}
onClick={() => { onClick={() => {
onDelete(); onDelete();
onClose?.(); onClose?.();
}} }}
> >
{t("Close")} {t("Close Connection")}
</Button> </Button>
</Box> </Box>
</Box> </Box>

View File

@ -7,6 +7,7 @@ import {
} from "@mui/x-data-grid"; } from "@mui/x-data-grid";
import { truncateStr } from "@/utils/truncate-str"; import { truncateStr } from "@/utils/truncate-str";
import parseTraffic from "@/utils/parse-traffic"; import parseTraffic from "@/utils/parse-traffic";
import { t } from "i18next";
interface Props { interface Props {
connections: IConnectionsItem[]; connections: IConnectionsItem[];
@ -21,10 +22,10 @@ export const ConnectionTable = (props: Props) => {
>({}); >({});
const columns: GridColDef[] = [ const columns: GridColDef[] = [
{ field: "host", headerName: "Host", flex: 220, minWidth: 220 }, { field: "host", headerName: t("Host"), flex: 220, minWidth: 220 },
{ {
field: "download", field: "download",
headerName: "Download", headerName: t("Downloaded"),
width: 88, width: 88,
align: "right", align: "right",
headerAlign: "right", headerAlign: "right",
@ -33,7 +34,7 @@ export const ConnectionTable = (props: Props) => {
}, },
{ {
field: "upload", field: "upload",
headerName: "Upload", headerName: t("Uploaded"),
width: 88, width: 88,
align: "right", align: "right",
headerAlign: "right", headerAlign: "right",
@ -42,7 +43,7 @@ export const ConnectionTable = (props: Props) => {
}, },
{ {
field: "dlSpeed", field: "dlSpeed",
headerName: "DL Speed", headerName: t("DL Speed"),
width: 88, width: 88,
align: "right", align: "right",
headerAlign: "right", headerAlign: "right",
@ -51,19 +52,19 @@ export const ConnectionTable = (props: Props) => {
}, },
{ {
field: "ulSpeed", field: "ulSpeed",
headerName: "UL Speed", headerName: t("UL Speed"),
width: 88, width: 88,
align: "right", align: "right",
headerAlign: "right", headerAlign: "right",
valueFormatter: (params: GridValueFormatterParams<number>) => valueFormatter: (params: GridValueFormatterParams<number>) =>
parseTraffic(params.value).join(" ") + "/s", parseTraffic(params.value).join(" ") + "/s",
}, },
{ field: "chains", headerName: "Chains", flex: 360, minWidth: 360 }, { field: "chains", headerName: t("Chains"), flex: 360, minWidth: 360 },
{ field: "rule", headerName: "Rule", flex: 300, minWidth: 250 }, { field: "rule", headerName: t("Rule"), flex: 300, minWidth: 250 },
{ field: "process", headerName: "Process", flex: 240, minWidth: 120 }, { field: "process", headerName: t("Process"), flex: 240, minWidth: 120 },
{ {
field: "time", field: "time",
headerName: "Time", headerName: t("Time"),
flex: 120, flex: 120,
minWidth: 100, minWidth: 100,
align: "right", align: "right",
@ -74,14 +75,14 @@ export const ConnectionTable = (props: Props) => {
valueFormatter: (params: GridValueFormatterParams<string>) => valueFormatter: (params: GridValueFormatterParams<string>) =>
dayjs(params.value).fromNow(), dayjs(params.value).fromNow(),
}, },
{ field: "source", headerName: "Source", flex: 200, minWidth: 130 }, { field: "source", headerName: t("Source"), flex: 200, minWidth: 130 },
{ {
field: "destinationIP", field: "destinationIP",
headerName: "Destination IP", headerName: t("Destination IP"),
flex: 200, flex: 200,
minWidth: 130, minWidth: 130,
}, },
{ field: "type", headerName: "Type", flex: 160, minWidth: 100 }, { field: "type", headerName: t("Type"), flex: 160, minWidth: 100 },
]; ];
const connRows = useMemo(() => { const connRows = useMemo(() => {

View File

@ -25,6 +25,7 @@
"Test URL": "Test URL", "Test URL": "Test URL",
"Test All": "Test All", "Test All": "Test All",
"Paste": "Paste",
"Profiles": "Profiles", "Profiles": "Profiles",
"Profile URL": "Profile URL", "Profile URL": "Profile URL",
"Import": "Import", "Import": "Import",
@ -70,6 +71,19 @@
"Update All": "Update All", "Update All": "Update All",
"Update At": "Update At", "Update At": "Update At",
"Host": "Host",
"Downloaded": "Downloaded",
"Uploaded": "Uploaded",
"DL Speed": "DL Speed",
"UL Speed": "UL Speed",
"Chains": "Chains",
"Rule": "Rule",
"Process": "Process",
"Time": "Time",
"Source": "Source",
"Destination IP": "Destination IP",
"Close Connection": "Close Connection",
"Type": "Type", "Type": "Type",
"Name": "Name", "Name": "Name",
"Descriptions": "Descriptions", "Descriptions": "Descriptions",

View File

@ -25,6 +25,7 @@
"Test URL": "Тестовый URL", "Test URL": "Тестовый URL",
"Test All": "Тест Все", "Test All": "Тест Все",
"Paste": "Вставить",
"Profiles": "Профили", "Profiles": "Профили",
"Profile URL": "URL профиля", "Profile URL": "URL профиля",
"Import": "Импорт", "Import": "Импорт",
@ -70,6 +71,19 @@
"Update All": "Обновить все", "Update All": "Обновить все",
"Update At": "Обновлено в", "Update At": "Обновлено в",
"Host": "Хост",
"Downloaded": "Скачано",
"Uploaded": "Загружено",
"DL Speed": "Скорость загрузки",
"UL Speed": "Скорость выгрузки",
"Chains": "Цепочки",
"Rule": "Правило",
"Process": "Процесс",
"Time": "Время подключения",
"Source": "Исходный адрес",
"Destination IP": "IP-адрес назначения",
"Close Connection": "Закрыть соединение",
"Type": "Тип", "Type": "Тип",
"Name": "Название", "Name": "Название",
"Descriptions": "Описания", "Descriptions": "Описания",

View File

@ -25,6 +25,7 @@
"Test URL": "测试地址", "Test URL": "测试地址",
"Test All": "测试全部", "Test All": "测试全部",
"Paste": "粘贴",
"Profiles": "订阅", "Profiles": "订阅",
"Profile URL": "订阅文件链接", "Profile URL": "订阅文件链接",
"Import": "导入", "Import": "导入",
@ -70,6 +71,19 @@
"Update All": "更新全部", "Update All": "更新全部",
"Update At": "更新于", "Update At": "更新于",
"Host": "主机",
"Downloaded": "下载量",
"Uploaded": "上传量",
"DL Speed": "下载速度",
"UL Speed": "上传速度",
"Chains": "链路",
"Rule": "规则",
"Process": "进程",
"Time": "连接时间",
"Source": "源地址",
"Destination IP": "目标地址",
"Close Connection": "关闭连接",
"Type": "类型", "Type": "类型",
"Name": "名称", "Name": "名称",
"Descriptions": "描述", "Descriptions": "描述",

View File

@ -134,8 +134,12 @@ const ConnectionsPage = () => {
contentStyle={{ height: "100%" }} contentStyle={{ height: "100%" }}
header={ header={
<Box sx={{ display: "flex", alignItems: "center", gap: 2 }}> <Box sx={{ display: "flex", alignItems: "center", gap: 2 }}>
<Box sx={{ mx: 1 }}>Download: {parseTraffic(download)}</Box> <Box sx={{ mx: 1 }}>
<Box sx={{ mx: 1 }}>Upload: {parseTraffic(upload)}</Box> {t("Downloaded")}: {parseTraffic(download)}
</Box>
<Box sx={{ mx: 1 }}>
{t("Uploaded")}: {parseTraffic(upload)}
</Box>
<IconButton <IconButton
color="inherit" color="inherit"
size="small" size="small"