From 743963318f2755cde031ab771a98dc1ca3b7e299 Mon Sep 17 00:00:00 2001 From: GyDi Date: Fri, 18 Mar 2022 14:59:23 +0800 Subject: [PATCH] feat: fill i18n --- src/components/profile/profile-item.tsx | 7 +++---- src/components/profile/profile-more.tsx | 8 ++++---- src/locales/en.json | 11 +++++++++++ src/locales/zh.json | 11 +++++++++++ 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/components/profile/profile-item.tsx b/src/components/profile/profile-item.tsx index b746ee4..c862259 100644 --- a/src/components/profile/profile-item.tsx +++ b/src/components/profile/profile-item.tsx @@ -2,6 +2,7 @@ import dayjs from "dayjs"; import { useLockFn } from "ahooks"; import { useSWRConfig } from "swr"; import { useEffect, useState } from "react"; +import { useTranslation } from "react-i18next"; import { alpha, Box, @@ -16,13 +17,10 @@ import { import { RefreshRounded } from "@mui/icons-material"; import { CmdType } from "../../services/types"; import { updateProfile, deleteProfile, viewProfile } from "../../services/cmds"; -import relativeTime from "dayjs/plugin/relativeTime"; import parseTraffic from "../../utils/parse-traffic"; import ProfileEdit from "./profile-edit"; import Notice from "../base/base-notice"; -dayjs.extend(relativeTime); - const Wrapper = styled(Box)(({ theme }) => ({ width: "100%", display: "block", @@ -51,6 +49,7 @@ interface Props { const ProfileItem = (props: Props) => { const { selected, itemData, onSelect } = props; + const { t } = useTranslation(); const { mutate } = useSWRConfig(); const [loading, setLoading] = useState(loadingCache[itemData.uid] ?? false); const [anchorEl, setAnchorEl] = useState(null); @@ -271,7 +270,7 @@ const ProfileItem = (props: Props) => { onClick={item.handler} sx={{ minWidth: 133 }} > - {item.label} + {t(item.label)} ))} diff --git a/src/components/profile/profile-more.tsx b/src/components/profile/profile-more.tsx index 56c4ab6..22f5b5d 100644 --- a/src/components/profile/profile-more.tsx +++ b/src/components/profile/profile-more.tsx @@ -1,5 +1,6 @@ import dayjs from "dayjs"; import { useEffect, useState } from "react"; +import { useTranslation } from "react-i18next"; import { alpha, Box, @@ -11,13 +12,10 @@ import { } from "@mui/material"; import { CmdType } from "../../services/types"; import { viewProfile } from "../../services/cmds"; -import relativeTime from "dayjs/plugin/relativeTime"; import ProfileEdit from "./profile-edit"; import Notice from "../base/base-notice"; import enhance from "../../services/enhance"; -dayjs.extend(relativeTime); - const Wrapper = styled(Box)(({ theme }) => ({ width: "100%", display: "block", @@ -54,6 +52,8 @@ const ProfileMore = (props: Props) => { } = props; const { uid, type } = itemData; + const { t } = useTranslation(); + const [anchorEl, setAnchorEl] = useState(null); const [position, setPosition] = useState({ left: 0, top: 0 }); const [editOpen, setEditOpen] = useState(false); @@ -221,7 +221,7 @@ const ProfileMore = (props: Props) => { onClick={item.handler} sx={{ minWidth: 133 }} > - {item.label} + {t(item.label)} ))} diff --git a/src/locales/en.json b/src/locales/en.json index fc27bef..d357734 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -18,6 +18,17 @@ "Import": "Import", "New": "New", "Close All": "Close All", + "Select": "Select", + "Edit": "Edit", + "File": "File", + "Update": "Update", + "Update(Proxy)": "Update(Proxy)", + "Delete": "Delete", + "Enable": "Enable", + "Disable": "Disable", + "Refresh": "Refresh", + "To Top": "To Top", + "To End": "To End", "Settings": "Settings", "Clash Setting": "Clash Setting", diff --git a/src/locales/zh.json b/src/locales/zh.json index 737a03d..7ca3a32 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -18,6 +18,17 @@ "Import": "导入", "New": "新建", "Close All": "关闭全部", + "Select": "使用", + "Edit": "编辑信息", + "File": "打开文件", + "Update": "更新", + "Update(Proxy)": "更新(代理)", + "Delete": "删除", + "Enable": "启用", + "Disable": "禁用", + "Refresh": "刷新", + "To Top": "移到最前", + "To End": "移到末尾", "Settings": "设置", "Clash Setting": "Clash 设置",