From 0e2854c09fce2daf767a752da44e3e62284a4ff4 Mon Sep 17 00:00:00 2001 From: Leo <1826234293@qq.com> Date: Tue, 29 Jun 2021 19:43:58 +0800 Subject: [PATCH] feat(i18n): flat-desktop support language switching (#775) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(i18n): add ErrorCode态DeviceCheck * feat(i18n): flat-desktop support language switching * refactor(i18n): Adjust text --- .../GeneralSettingPage/index.tsx | 21 ++++++++++++++----- packages/flat-i18n/locales/en.json | 4 ++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/desktop/renderer-app/src/pages/UserSettingPage/GeneralSettingPage/index.tsx b/desktop/renderer-app/src/pages/UserSettingPage/GeneralSettingPage/index.tsx index 97a304a9716..81f83e3232b 100644 --- a/desktop/renderer-app/src/pages/UserSettingPage/GeneralSettingPage/index.tsx +++ b/desktop/renderer-app/src/pages/UserSettingPage/GeneralSettingPage/index.tsx @@ -1,6 +1,7 @@ import "./style.less"; import { Checkbox, Radio } from "antd"; +import type { CheckboxChangeEvent } from "antd/lib/checkbox"; import React, { useEffect, useState } from "react"; import { UserSettingLayoutContainer } from "../UserSettingLayoutContainer"; import { ipcSyncByApp, ipcAsyncByApp } from "../../../utils/ipc"; @@ -12,7 +13,7 @@ enum SelectLanguage { } export const GeneralSettingPage = (): React.ReactElement => { - const { t } = useTranslation(); + const { t, i18n } = useTranslation(); const [openAtLogin, setOpenAtLogin] = useState(false); useEffect(() => { @@ -32,6 +33,11 @@ export const GeneralSettingPage = (): React.ReactElement => { }); }; + async function changeLanguage(event: CheckboxChangeEvent): Promise { + const language: SelectLanguage = event.target.value; + await i18n.changeLanguage(language === SelectLanguage.Chinese ? "zh-CN" : "en"); + } + return (
@@ -42,11 +48,16 @@ export const GeneralSettingPage = (): React.ReactElement => {
{t("language-settings")} - + {t("chinese")} - - English - + English
diff --git a/packages/flat-i18n/locales/en.json b/packages/flat-i18n/locales/en.json index 05b4e1d59dd..fdd3be8a901 100644 --- a/packages/flat-i18n/locales/en.json +++ b/packages/flat-i18n/locales/en.json @@ -60,9 +60,9 @@ "the-room-has-ended-and-is-about-to-exit": "The room has ended and is about to exit...", "you-have-entered-the-room-at-another-device": "You have entered the room at another device", "class-picker-text": { - "BigClass": "1 teacher for a large number of students", + "BigClass": "Large number of students", "OneToOne": "1 teacher and 1 student", - "SmallClass": "1 teacher for up to 16 students" + "SmallClass": "Up to 16 students" }, "class-room-type": { "BigClass": "Large Class",