Skip to content

Commit

Permalink
feat(frontend): add change language button in personal setting
Browse files Browse the repository at this point in the history
  • Loading branch information
gangjun06 committed Dec 2, 2022
1 parent 9685af2 commit 6cebe17
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 11 deletions.
1 change: 0 additions & 1 deletion frontend/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"simple-import-sort"
],
"rules": {
"i18n-ally-translation-missing": "off",
"react-hooks/exhaustive-deps": "off",
"simple-import-sort/exports": "warn",
"simple-import-sort/imports": [
Expand Down
3 changes: 2 additions & 1 deletion frontend/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"i18n-ally.localesPaths": [
"locales",
"public/locales"
]
],
"i18n-ally.sourceLanguage": "en-US"
}
4 changes: 2 additions & 2 deletions frontend/components/basic/dialog/AddServiceTokenDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const AddServiceTokenDialog = ({
"Testing",
]}
width="full"
text={`t("common:environment"): `}
text={`${t("common:environment")}: `}
/>
</div>
<div className="max-h-28">
Expand All @@ -177,7 +177,7 @@ const AddServiceTokenDialog = ({
onChange={setServiceTokenExpiresIn}
data={["1 day", "7 days", "1 month"]}
width="full"
text={`t("common:expired-in"): `}
text={`${t("common:expired-in")}: `}
/>
</div>
<div className="max-w-max">
Expand Down
2 changes: 1 addition & 1 deletion frontend/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
"section-incident",
"section-members",
],
"/settings/personal/[id]": ["settings-personal"],
"/settings/personal/[id]": ["settings-personal", "form-password"],
"/settings/billing/[id]": ["billing"],
"/integrations/[id]": ["integrations"],
},
Expand Down
6 changes: 4 additions & 2 deletions frontend/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"custom-pricing": "Custom Pricing",
"schedule-demo": "Schedule a Demo",
"environment": "Environment",
"expired-in": "Expires in"
"expired-in": "Expires in",
"language": "Language"
},
"form-password": {
"password": "Password",
Expand Down Expand Up @@ -132,7 +133,8 @@
"text1": "Your Emergency Kit contains the information you’ll need to sign in to your Infisical account.",
"text2": "Only the latest issued Emergency Kit remains valid. To get a new Emergency Kit, verify your password.",
"download": "Download Emergency Kit"
}
},
"change-language": "Change Language"
},
"settings-project": {
"title": "Project Settings",
Expand Down
8 changes: 6 additions & 2 deletions frontend/locales/ko-KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
"upgrade": "Upgrade",
"learn-more": "Learn More",
"custom-pricing": "Custom Pricing",
"schedule-demo": "Schedule a Demo"
"schedule-demo": "Schedule a Demo",
"environment": "환경",
"expired-in": "만료 기한:",
"language": "언어"
},
"form-password": {
"password": "비밀번호",
Expand Down Expand Up @@ -130,7 +133,8 @@
"text1": "긴급복구 키트는 Infisical계정에 로그인 할 수 있는 정보를 가지고 있어요.",
"text2": "오직 마지막으로 발급한 긴급복구 키트만 사용 가능해요. 새로운 긴급복구 키트를 받으려면, 비밀번호를 입력하세요.",
"download": "긴급복구 키트 다운로드"
}
},
"change-language": "언어 변경하기"
},
"settings-project": {
"title": "프로젝트 설정",
Expand Down
25 changes: 23 additions & 2 deletions frontend/pages/settings/personal/[id].js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React, { useEffect, useState } from "react";
import React, { useCallback, useEffect, useState } from "react";
import Head from "next/head";
import setLanguage from "next-translate/setLanguage";
import useTranslation from "next-translate/useTranslation";
import { faCheck, faX } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";

import Button from "~/components/basic/buttons/Button";
import InputField from "~/components/basic/InputField";
import ListBox from "~/components/basic/Listbox";
import NavHeader from "~/components/navigation/NavHeader";
import changePassword from "~/components/utilities/cryptography/changePassword";
import issueBackupKey from "~/components/utilities/cryptography/issueBackupKey";
Expand All @@ -27,7 +29,11 @@ export default function PersonalSettings() {
const [backupKeyIssued, setBackupKeyIssued] = useState(false);
const [backupKeyError, setBackupKeyError] = useState(false);

const { t } = useTranslation();
const { t, lang } = useTranslation();

const changeLanguage = useCallback((code) => {
setLanguage(code);
}, []);

useEffect(async () => {
let user = await getUser();
Expand Down Expand Up @@ -108,6 +114,21 @@ export default function PersonalSettings() {
</div> */}
</div>
</div>
<div className="bg-white/5 rounded-md px-6 pt-6 pb-6 flex flex-col items-start flex flex-col items-start w-full mb-6 mt-4">
<p className="text-xl font-semibold self-start">
{t("settings-personal:change-language")}
</p>
<div className="max-h-28 w-ful mt-4">
<ListBox
selected={lang}
onChange={setLanguage}
data={["en-US", "ko-KR"]}
width="full"
text={`${t("common:language")}: `}
/>
</div>
</div>

<div className="bg-white/5 rounded-md px-6 pt-5 pb-6 flex flex-col items-start flex flex-col items-start w-full mb-6">
<div className="flex flex-row max-w-5xl justify-between items-center w-full">
<div className="flex flex-col justify-between w-full max-w-3xl">
Expand Down

0 comments on commit 6cebe17

Please sign in to comment.