From f3f48e2753af005284266cb87369d0860539d991 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Mon, 1 Jul 2024 14:41:16 +0800 Subject: [PATCH] feat: refine 2fa-related i18n (#6228) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /area ui /kind feature /milestone 2.17.x #### What this PR does / why we need it: 补充 2FA 相关的 i18n 定义。 #### Does this PR introduce a user-facing change? ```release-note None ``` --- ui/src/components/login/MfaForm.vue | 33 +++++++++-- ui/src/locales/en.yaml | 53 ++++++++++++++++++ ui/src/locales/zh-CN.yaml | 51 +++++++++++++++++ ui/src/locales/zh-TW.yaml | 51 +++++++++++++++++ ui/uc-src/modules/profile/Profile.vue | 2 +- ui/uc-src/modules/profile/tabs/TwoFactor.vue | 34 ++++++++--- .../components/PasswordValidationForm.vue | 8 ++- .../tabs/components/TotpConfigureModal.vue | 56 +++++++++++++++---- .../tabs/components/TotpDeletionModal.vue | 12 ++-- .../tabs/components/TwoFactorDisableModal.vue | 12 ++-- .../tabs/components/TwoFactorEnableModal.vue | 12 ++-- 11 files changed, 285 insertions(+), 39 deletions(-) diff --git a/ui/src/components/login/MfaForm.vue b/ui/src/components/login/MfaForm.vue index e92e84ee0..fae66a66c 100644 --- a/ui/src/components/login/MfaForm.vue +++ b/ui/src/components/login/MfaForm.vue @@ -1,15 +1,24 @@ diff --git a/ui/src/locales/en.yaml b/ui/src/locales/en.yaml index f0aca3625..0980d0213 100644 --- a/ui/src/locales/en.yaml +++ b/ui/src/locales/en.yaml @@ -25,6 +25,11 @@ core: button: Login modal: title: Re-login + 2fa: + fields: + code: + placeholder: Two-step verification code + label: Two-step verification code signup: title: Sign up fields: @@ -1161,6 +1166,7 @@ core: detail: Detail notification-preferences: Notification Preferences pat: Personal Access Tokens + 2fa: 2FA devices: Devices actions: update_profile: @@ -1194,6 +1200,49 @@ core: title: Verify email email_verified: tooltip: Verified + 2fa: + operations: + enable: + button: Enable 2FA + title: Enable 2FA + disable: + title: Disable 2FA + disable_totp: + title: Disable TOTP + password_validation_form: + fields: + password: + label: Password + help: Login password of the current account + methods: + title: Two-factor methods + totp: + title: TOTP + description: Configure two-step verification with TOTP application + fields: + status: + configured: Configured + not_configured: Not configured + operations: + reconfigure: + button: Reconfigure + configure: + button: Configure + title: TOTP configuration + fields: + code: + label: Verification code + help: >- + 6-digit verification code obtained from the validator + application + password: + label: Password + help: Login password of the current account + qrcode: + label: "Use the validator application to scan the QR code below:" + manual: + label: "If you can't scan the QR code, click to view the alternative steps." + help: "Manually configure the validator application with the following code:" pat: operations: delete: @@ -1707,6 +1756,8 @@ core: access: Access schedule_publish: Schedule publish revoke: Revoke + disable: Disable + enable: Enable radio: "yes": "Yes" "no": "No" @@ -1739,6 +1790,8 @@ core: not_found: Resource not found server_internal_error: Internal server error unknown_error: Unknown error + disable_success: Disabled successfully + enable_success: Enabled successfully dialog: titles: tip: Tip diff --git a/ui/src/locales/zh-CN.yaml b/ui/src/locales/zh-CN.yaml index e39b65b16..6e77cb66e 100644 --- a/ui/src/locales/zh-CN.yaml +++ b/ui/src/locales/zh-CN.yaml @@ -25,6 +25,11 @@ core: button: 登录 modal: title: 重新登录 + 2fa: + fields: + code: + placeholder: 请输入两步验证码 + label: 两步验证码 signup: title: 注册 fields: @@ -1086,6 +1091,7 @@ core: detail: 详情 notification-preferences: 通知配置 pat: 个人令牌 + 2fa: 两步验证 devices: 登录设备 actions: update_profile: @@ -1115,6 +1121,47 @@ core: description: 电子邮箱地址还未验证,点击下方按钮进行验证 email_verified: tooltip: 已验证 + 2fa: + operations: + enable: + button: 启用两步验证 + title: 启用两步验证 + disable: + title: 禁用两步验证 + disable_totp: + title: 停用 TOTP + password_validation_form: + fields: + password: + label: 验证密码 + help: 当前账号的登录密码 + methods: + title: 验证方式 + totp: + title: TOTP + description: 使用 TOTP 应用程序配置两步验证 + fields: + status: + configured: 已配置 + not_configured: 未配置 + operations: + reconfigure: + button: 重新配置 + configure: + button: 配置 + title: TOTP 配置 + fields: + code: + label: 验证码 + help: 从验证器应用获得的 6 位验证码 + password: + label: 验证密码 + help: 当前账号的登录密码 + qrcode: + label: 使用验证器应用扫描下方二维码: + manual: + label: 如果无法扫描二维码,点击查看代替步骤 + help: 使用以下代码手动配置验证器应用: pat: operations: delete: @@ -1624,6 +1671,8 @@ core: access: 访问 schedule_publish: 定时发布 revoke: 撤销 + disable: 禁用 + enable: 启用 radio: "yes": 是 "no": 否 @@ -1656,6 +1705,8 @@ core: not_found: 资源不存在 server_internal_error: 服务器内部错误 unknown_error: 未知错误 + disable_success: 禁用成功 + enable_success: 啟用成功 dialog: titles: tip: 提示 diff --git a/ui/src/locales/zh-TW.yaml b/ui/src/locales/zh-TW.yaml index 195e6d986..9e384b65e 100644 --- a/ui/src/locales/zh-TW.yaml +++ b/ui/src/locales/zh-TW.yaml @@ -25,6 +25,11 @@ core: button: 登入 modal: title: 重新登入 + 2fa: + fields: + code: + placeholder: 請輸入兩步驟驗證碼 + label: 兩步驟驗證碼 signup: title: 註冊 fields: @@ -1066,6 +1071,7 @@ core: detail: 詳情 notification-preferences: 通知配置 pat: 個人令牌 + 2fa: 两步验证 devices: 登錄設備 actions: update_profile: @@ -1095,6 +1101,47 @@ core: title: 驗證電子郵件信箱 email_verified: tooltip: 已驗證 + 2fa: + operations: + enable: + button: 启用两步验证 + title: 启用两步验证 + disable: + title: 禁用两步验证 + disable_totp: + title: 停用 TOTP + password_validation_form: + fields: + password: + label: 验证密碼 + help: 目前帳號的登入密碼 + methods: + title: 驗證方法 + totp: + title: TOTP + description: 使用 TOTP 應用程式設定兩步驟驗證 + fields: + status: + configured: 已配置 + not_configured: 未配置 + operations: + reconfigure: + button: 重新配置 + configure: + button: 配置 + title: TOTP 配置 + fields: + code: + label: 驗證碼 + help: 從驗證器應用程式取得的 6 位驗證碼 + password: + label: 验证密碼 + help: 目前帳號的登入密碼 + qrcode: + label: 使用驗證器應用程式掃描下面的二維碼: + manual: + label: 如果您無法掃描二維碼,請按一下查看替代步驟。 + help: 使用以下程式碼手動配置驗證器應用程式: pat: operations: delete: @@ -1581,6 +1628,8 @@ core: access: 訪問 schedule_publish: 定時發佈 revoke: 撤銷 + disable: 禁用 + enable: 启用 radio: "yes": 是 "no": 否 @@ -1613,6 +1662,8 @@ core: not_found: 資源不存在 server_internal_error: 伺服器內部錯誤 unknown_error: 未知錯誤 + disable_success: 禁用成功 + enable_success: 啟用成功 dialog: titles: tip: 提示 diff --git a/ui/uc-src/modules/profile/Profile.vue b/ui/uc-src/modules/profile/Profile.vue index d8518d88b..604e37c9c 100644 --- a/ui/uc-src/modules/profile/Profile.vue +++ b/ui/uc-src/modules/profile/Profile.vue @@ -70,7 +70,7 @@ const tabs = ref([ }, { id: "2fa", - label: "两步验证", + label: t("core.uc_profile.tabs.2fa"), component: markRaw(TwoFactor), priority: 40, }, diff --git a/ui/uc-src/modules/profile/tabs/TwoFactor.vue b/ui/uc-src/modules/profile/tabs/TwoFactor.vue index eadbf4f61..d7306e6a3 100644 --- a/ui/uc-src/modules/profile/tabs/TwoFactor.vue +++ b/ui/uc-src/modules/profile/tabs/TwoFactor.vue @@ -51,7 +51,9 @@ const totpDeletionModalVisible = ref(false); :checked="settings?.enabled" @change="onEnabledChange" /> - 启用两步验证 + + {{ $t("core.uc_profile.2fa.operations.enable.button") }} + @@ -63,7 +65,9 @@ const totpDeletionModalVisible = ref(false); role="list" >
  • - 验证方式 + + {{ $t("core.uc_profile.2fa.methods.title") }} +
  • @@ -74,20 +78,36 @@ const totpDeletionModalVisible = ref(false); diff --git a/ui/uc-src/modules/profile/tabs/components/TotpDeletionModal.vue b/ui/uc-src/modules/profile/tabs/components/TotpDeletionModal.vue index 223cd70f6..b6c8c2617 100644 --- a/ui/uc-src/modules/profile/tabs/components/TotpDeletionModal.vue +++ b/ui/uc-src/modules/profile/tabs/components/TotpDeletionModal.vue @@ -3,9 +3,11 @@ import { ucApiClient } from "@halo-dev/api-client"; import { Toast, VButton, VModal, VSpace } from "@halo-dev/components"; import { useMutation, useQueryClient } from "@tanstack/vue-query"; import { ref } from "vue"; +import { useI18n } from "vue-i18n"; import PasswordValidationForm from "./PasswordValidationForm.vue"; const queryClient = useQueryClient(); +const { t } = useI18n(); const emit = defineEmits<{ (event: "close"): void; @@ -23,7 +25,7 @@ const { mutate, isLoading } = useMutation({ }); }, onSuccess() { - Toast.success("停用成功"); + Toast.success(t("core.common.toast.disable_success")); queryClient.invalidateQueries({ queryKey: ["two-factor-settings"] }); modal.value?.close(); }, @@ -39,7 +41,7 @@ function onSubmit(password: string) { ref="modal" :width="500" :centered="false" - title="停用 TOTP" + :title="$t('core.uc_profile.2fa.operations.disable_totp.title')" @close="emit('close')" > @@ -50,9 +52,11 @@ function onSubmit(password: string) { type="danger" @click="$formkit.submit('password-validation-form')" > - 停用 + {{ $t("core.common.buttons.disable") }} + + + {{ $t("core.common.buttons.close") }} - 关闭 diff --git a/ui/uc-src/modules/profile/tabs/components/TwoFactorDisableModal.vue b/ui/uc-src/modules/profile/tabs/components/TwoFactorDisableModal.vue index 492ad9889..314dad227 100644 --- a/ui/uc-src/modules/profile/tabs/components/TwoFactorDisableModal.vue +++ b/ui/uc-src/modules/profile/tabs/components/TwoFactorDisableModal.vue @@ -3,9 +3,11 @@ import { ucApiClient } from "@halo-dev/api-client"; import { Toast, VButton, VModal, VSpace } from "@halo-dev/components"; import { useMutation, useQueryClient } from "@tanstack/vue-query"; import { ref } from "vue"; +import { useI18n } from "vue-i18n"; import PasswordValidationForm from "./PasswordValidationForm.vue"; const queryClient = useQueryClient(); +const { t } = useI18n(); const emit = defineEmits<{ (event: "close"): void; @@ -23,7 +25,7 @@ const { mutate, isLoading } = useMutation({ }); }, onSuccess() { - Toast.success("停用成功"); + Toast.success(t("core.common.toast.disable_success")); queryClient.invalidateQueries({ queryKey: ["two-factor-settings"] }); modal.value?.close(); }, @@ -39,7 +41,7 @@ function onSubmit(password: string) { ref="modal" :width="500" :centered="false" - title="停用两步验证" + :title="$t('core.uc_profile.2fa.operations.disable.title')" @close="emit('close')" > @@ -50,9 +52,11 @@ function onSubmit(password: string) { type="danger" @click="$formkit.submit('password-validation-form')" > - 停用 + {{ $t("core.common.buttons.disable") }} + + + {{ $t("core.common.buttons.close") }} - 关闭 diff --git a/ui/uc-src/modules/profile/tabs/components/TwoFactorEnableModal.vue b/ui/uc-src/modules/profile/tabs/components/TwoFactorEnableModal.vue index 7ec71ddc5..0093c38d1 100644 --- a/ui/uc-src/modules/profile/tabs/components/TwoFactorEnableModal.vue +++ b/ui/uc-src/modules/profile/tabs/components/TwoFactorEnableModal.vue @@ -3,9 +3,11 @@ import { ucApiClient } from "@halo-dev/api-client"; import { Toast, VButton, VModal, VSpace } from "@halo-dev/components"; import { useMutation, useQueryClient } from "@tanstack/vue-query"; import { ref } from "vue"; +import { useI18n } from "vue-i18n"; import PasswordValidationForm from "./PasswordValidationForm.vue"; const queryClient = useQueryClient(); +const { t } = useI18n(); const emit = defineEmits<{ (event: "close"): void; @@ -23,7 +25,7 @@ const { mutate, isLoading } = useMutation({ }); }, onSuccess() { - Toast.success("启用成功"); + Toast.success(t("core.common.toast.enable_success")); queryClient.invalidateQueries({ queryKey: ["two-factor-settings"] }); modal.value?.close(); }, @@ -39,7 +41,7 @@ function onSubmit(password: string) { ref="modal" :width="500" :centered="false" - title="启用两步验证" + :title="$t('core.uc_profile.2fa.operations.enable.title')" @close="emit('close')" > @@ -50,9 +52,11 @@ function onSubmit(password: string) { type="secondary" @click="$formkit.submit('password-validation-form')" > - 启用 + {{ $t("core.common.buttons.enable") }} + + + {{ $t("core.common.buttons.close") }} - 关闭