From 7348f47ef84443c18ff0604c04936a9a8f2d0810 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 5 Sep 2023 22:10:23 +0800 Subject: [PATCH] chore: update i18n locales --- api/v2/user_setting_service.go | 3 ++- frontend/locales/en.json | 7 +++++-- frontend/locales/zh.json | 7 +++++-- frontend/web/src/components/setting/AccessTokenSection.tsx | 6 ++++-- frontend/web/src/components/setting/AccountSection.tsx | 6 ++++-- frontend/web/src/pages/Home.tsx | 6 ++++-- frontend/web/src/pages/ShortcutDetail.tsx | 6 +++--- frontend/web/src/pages/SignIn.tsx | 6 ++++-- frontend/web/src/pages/SignUp.tsx | 6 ++++-- 9 files changed, 35 insertions(+), 18 deletions(-) diff --git a/api/v2/user_setting_service.go b/api/v2/user_setting_service.go index 349aa71..19b0ebd 100644 --- a/api/v2/user_setting_service.go +++ b/api/v2/user_setting_service.go @@ -74,7 +74,8 @@ func getUserSetting(ctx context.Context, s *store.Store, userID int32) (*apiv2pb } userSetting := &apiv2pb.UserSetting{ - Id: userID, + Id: userID, + Locale: apiv2pb.UserSetting_LOCALE_EN, } for _, setting := range userSettings { if setting.Key == storepb.UserSettingKey_USER_SETTING_LOCALE { diff --git a/frontend/locales/en.json b/frontend/locales/en.json index c45d713..b3dab6e 100644 --- a/frontend/locales/en.json +++ b/frontend/locales/en.json @@ -8,7 +8,10 @@ "download": "Download", "edit": "Edit", "delete": "Delete", - "language": "Language" + "language": "Language", + "search": "Search", + "email": "Email", + "password": "Password" }, "analytics": { "self": "Analytics", @@ -36,4 +39,4 @@ } } } -} \ No newline at end of file +} diff --git a/frontend/locales/zh.json b/frontend/locales/zh.json index 17e310f..42352f1 100644 --- a/frontend/locales/zh.json +++ b/frontend/locales/zh.json @@ -8,7 +8,10 @@ "download": "下载", "edit": "编辑", "delete": "删除", - "language": "语言" + "language": "语言", + "search": "搜索", + "email": "邮箱", + "password": "密码" }, "analytics": { "self": "分析", @@ -36,4 +39,4 @@ } } } -} \ No newline at end of file +} diff --git a/frontend/web/src/components/setting/AccessTokenSection.tsx b/frontend/web/src/components/setting/AccessTokenSection.tsx index 6e08a7e..2c9c691 100644 --- a/frontend/web/src/components/setting/AccessTokenSection.tsx +++ b/frontend/web/src/components/setting/AccessTokenSection.tsx @@ -3,6 +3,7 @@ import axios from "axios"; import copy from "copy-to-clipboard"; import { useEffect, useState } from "react"; import { toast } from "react-hot-toast"; +import { useTranslation } from "react-i18next"; import { ListUserAccessTokensResponse, UserAccessToken } from "@/types/proto/api/v2/user_service_pb"; import useUserStore from "../../stores/v1/user"; import { showCommonDialog } from "../Alert"; @@ -15,6 +16,7 @@ const listAccessTokens = async (userId: number) => { }; const AccessTokenSection = () => { + const { t } = useTranslation(); const currentUser = useUserStore().getCurrentUser(); const [userAccessTokens, setUserAccessTokens] = useState([]); const [showCreateDialog, setShowCreateDialog] = useState(false); @@ -68,7 +70,7 @@ const AccessTokenSection = () => { setShowCreateDialog(true); }} > - Create + {t("common.create")} @@ -91,7 +93,7 @@ const AccessTokenSection = () => { Expires At - Delete + {t("common.delete")} diff --git a/frontend/web/src/components/setting/AccountSection.tsx b/frontend/web/src/components/setting/AccountSection.tsx index 5a486ec..780a2f6 100644 --- a/frontend/web/src/components/setting/AccountSection.tsx +++ b/frontend/web/src/components/setting/AccountSection.tsx @@ -1,10 +1,12 @@ import { Button } from "@mui/joy"; import { useState } from "react"; +import { useTranslation } from "react-i18next"; import useUserStore from "../../stores/v1/user"; import ChangePasswordDialog from "../ChangePasswordDialog"; import EditUserinfoDialog from "../EditUserinfoDialog"; const AccountSection: React.FC = () => { + const { t } = useTranslation(); const currentUser = useUserStore().getCurrentUser(); const [showEditUserinfoDialog, setShowEditUserinfoDialog] = useState(false); const [showChangePasswordDialog, setShowChangePasswordDialog] = useState(false); @@ -19,12 +21,12 @@ const AccountSection: React.FC = () => { {isAdmin && Admin}

- Email: + {t("common.email")}: {currentUser.email}

@@ -57,7 +59,7 @@ const Home: React.FC = () => { className="w-32 ml-2" type="text" size="sm" - placeholder="Search" + placeholder={t("common.search")} startDecorator={} endDecorator={} value={filter.search} diff --git a/frontend/web/src/pages/ShortcutDetail.tsx b/frontend/web/src/pages/ShortcutDetail.tsx index f7696d6..19bdd5b 100644 --- a/frontend/web/src/pages/ShortcutDetail.tsx +++ b/frontend/web/src/pages/ShortcutDetail.tsx @@ -127,7 +127,7 @@ const ShortcutDetail = () => { }); }} > - Edit + {t("common.edit")} } @@ -177,7 +177,7 @@ const ShortcutDetail = () => {

- Analytics + {t("analytics.self")}

diff --git a/frontend/web/src/pages/SignIn.tsx b/frontend/web/src/pages/SignIn.tsx index 0439a1f..0892ae5 100644 --- a/frontend/web/src/pages/SignIn.tsx +++ b/frontend/web/src/pages/SignIn.tsx @@ -1,6 +1,7 @@ import { Button, Input } from "@mui/joy"; import React, { FormEvent, useEffect, useState } from "react"; import { toast } from "react-hot-toast"; +import { useTranslation } from "react-i18next"; import { Link, useNavigate } from "react-router-dom"; import * as api from "../helpers/api"; import useLoading from "../hooks/useLoading"; @@ -8,6 +9,7 @@ import { useAppSelector } from "../stores"; import useUserStore from "../stores/v1/user"; const SignIn: React.FC = () => { + const { t } = useTranslation(); const navigate = useNavigate(); const userStore = useUserStore(); const { @@ -79,7 +81,7 @@ const SignIn: React.FC = () => {
- Email + {t("common.email")} { />
- Password + {t("common.password")}
diff --git a/frontend/web/src/pages/SignUp.tsx b/frontend/web/src/pages/SignUp.tsx index 0d7792e..449cad6 100644 --- a/frontend/web/src/pages/SignUp.tsx +++ b/frontend/web/src/pages/SignUp.tsx @@ -1,6 +1,7 @@ import { Button, Input } from "@mui/joy"; import React, { FormEvent, useEffect, useState } from "react"; import { toast } from "react-hot-toast"; +import { useTranslation } from "react-i18next"; import { Link, useNavigate } from "react-router-dom"; import * as api from "../helpers/api"; import useLoading from "../hooks/useLoading"; @@ -8,6 +9,7 @@ import { globalService } from "../services"; import useUserStore from "../stores/v1/user"; const SignUp: React.FC = () => { + const { t } = useTranslation(); const navigate = useNavigate(); const userStore = useUserStore(); const { @@ -84,7 +86,7 @@ const SignUp: React.FC = () => {
- Email + {t("common.email")} {
- Password + {t("common.password")}