Skip to content

Commit

Permalink
feat(i18n): flat-desktop support language switching (#775)
Browse files Browse the repository at this point in the history
* feat(i18n): add ErrorCode、DeviceCheck

* feat(i18n): flat-desktop support language switching

* refactor(i18n): Adjust text
  • Loading branch information
Leooeloel authored Jun 29, 2021
1 parent 6e5c84b commit 0e2854c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -12,7 +13,7 @@ enum SelectLanguage {
}

export const GeneralSettingPage = (): React.ReactElement => {
const { t } = useTranslation();
const { t, i18n } = useTranslation();
const [openAtLogin, setOpenAtLogin] = useState(false);

useEffect(() => {
Expand All @@ -32,6 +33,11 @@ export const GeneralSettingPage = (): React.ReactElement => {
});
};

async function changeLanguage(event: CheckboxChangeEvent): Promise<void> {
const language: SelectLanguage = event.target.value;
await i18n.changeLanguage(language === SelectLanguage.Chinese ? "zh-CN" : "en");
}

return (
<UserSettingLayoutContainer>
<div className="general-setting-container">
Expand All @@ -42,11 +48,16 @@ export const GeneralSettingPage = (): React.ReactElement => {
</div>
<div className="general-setting-select-language">
<span>{t("language-settings")}</span>
<Radio.Group defaultValue={SelectLanguage.Chinese}>
<Radio.Group
defaultValue={
i18n.language === "zh-CN"
? SelectLanguage.Chinese
: SelectLanguage.English
}
onChange={changeLanguage}
>
<Radio value={SelectLanguage.Chinese}>{t("chinese")}</Radio>
<Radio disabled value={SelectLanguage.English}>
English
</Radio>
<Radio value={SelectLanguage.English}>English</Radio>
</Radio.Group>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/flat-i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 0e2854c

Please sign in to comment.