feat(frontend): add change language button in personal setting

This commit is contained in:
이강준
2022-12-02 21:09:51 +09:00
parent 9685af21f3
commit 6cebe171d9
7 changed files with 38 additions and 11 deletions

View File

@@ -4,7 +4,6 @@
"simple-import-sort" "simple-import-sort"
], ],
"rules": { "rules": {
"i18n-ally-translation-missing": "off",
"react-hooks/exhaustive-deps": "off", "react-hooks/exhaustive-deps": "off",
"simple-import-sort/exports": "warn", "simple-import-sort/exports": "warn",
"simple-import-sort/imports": [ "simple-import-sort/imports": [

View File

@@ -2,5 +2,6 @@
"i18n-ally.localesPaths": [ "i18n-ally.localesPaths": [
"locales", "locales",
"public/locales" "public/locales"
] ],
"i18n-ally.sourceLanguage": "en-US"
} }

View File

@@ -168,7 +168,7 @@ const AddServiceTokenDialog = ({
"Testing", "Testing",
]} ]}
width="full" width="full"
text={`t("common:environment"): `} text={`${t("common:environment")}: `}
/> />
</div> </div>
<div className="max-h-28"> <div className="max-h-28">
@@ -177,7 +177,7 @@ const AddServiceTokenDialog = ({
onChange={setServiceTokenExpiresIn} onChange={setServiceTokenExpiresIn}
data={["1 day", "7 days", "1 month"]} data={["1 day", "7 days", "1 month"]}
width="full" width="full"
text={`t("common:expired-in"): `} text={`${t("common:expired-in")}: `}
/> />
</div> </div>
<div className="max-w-max"> <div className="max-w-max">

View File

@@ -20,7 +20,7 @@ module.exports = {
"section-incident", "section-incident",
"section-members", "section-members",
], ],
"/settings/personal/[id]": ["settings-personal"], "/settings/personal/[id]": ["settings-personal", "form-password"],
"/settings/billing/[id]": ["billing"], "/settings/billing/[id]": ["billing"],
"/integrations/[id]": ["integrations"], "/integrations/[id]": ["integrations"],
}, },

View File

@@ -30,7 +30,8 @@
"custom-pricing": "Custom Pricing", "custom-pricing": "Custom Pricing",
"schedule-demo": "Schedule a Demo", "schedule-demo": "Schedule a Demo",
"environment": "Environment", "environment": "Environment",
"expired-in": "Expires in" "expired-in": "Expires in",
"language": "Language"
}, },
"form-password": { "form-password": {
"password": "Password", "password": "Password",
@@ -132,7 +133,8 @@
"text1": "Your Emergency Kit contains the information you’ll need to sign in to your Infisical account.", "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.", "text2": "Only the latest issued Emergency Kit remains valid. To get a new Emergency Kit, verify your password.",
"download": "Download Emergency Kit" "download": "Download Emergency Kit"
} },
"change-language": "Change Language"
}, },
"settings-project": { "settings-project": {
"title": "Project Settings", "title": "Project Settings",

View File

@@ -28,7 +28,10 @@
"upgrade": "Upgrade", "upgrade": "Upgrade",
"learn-more": "Learn More", "learn-more": "Learn More",
"custom-pricing": "Custom Pricing", "custom-pricing": "Custom Pricing",
"schedule-demo": "Schedule a Demo" "schedule-demo": "Schedule a Demo",
"environment": "환경",
"expired-in": "만료 기한:",
"language": "언어"
}, },
"form-password": { "form-password": {
"password": "비밀번호", "password": "비밀번호",
@@ -130,7 +133,8 @@
"text1": "긴급복구 키트는 Infisical계정에 로그인 할 수 있는 정보를 가지고 있어요.", "text1": "긴급복구 키트는 Infisical계정에 로그인 할 수 있는 정보를 가지고 있어요.",
"text2": "오직 마지막으로 발급한 긴급복구 키트만 사용 가능해요. 새로운 긴급복구 키트를 받으려면, 비밀번호를 입력하세요.", "text2": "오직 마지막으로 발급한 긴급복구 키트만 사용 가능해요. 새로운 긴급복구 키트를 받으려면, 비밀번호를 입력하세요.",
"download": "긴급복구 키트 다운로드" "download": "긴급복구 키트 다운로드"
} },
"change-language": "언어 변경하기"
}, },
"settings-project": { "settings-project": {
"title": "프로젝트 설정", "title": "프로젝트 설정",

View File

@@ -1,11 +1,13 @@
import React, { useEffect, useState } from "react"; import React, { useCallback, useEffect, useState } from "react";
import Head from "next/head"; import Head from "next/head";
import setLanguage from "next-translate/setLanguage";
import useTranslation from "next-translate/useTranslation"; import useTranslation from "next-translate/useTranslation";
import { faCheck, faX } from "@fortawesome/free-solid-svg-icons"; import { faCheck, faX } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import Button from "~/components/basic/buttons/Button"; import Button from "~/components/basic/buttons/Button";
import InputField from "~/components/basic/InputField"; import InputField from "~/components/basic/InputField";
import ListBox from "~/components/basic/Listbox";
import NavHeader from "~/components/navigation/NavHeader"; import NavHeader from "~/components/navigation/NavHeader";
import changePassword from "~/components/utilities/cryptography/changePassword"; import changePassword from "~/components/utilities/cryptography/changePassword";
import issueBackupKey from "~/components/utilities/cryptography/issueBackupKey"; import issueBackupKey from "~/components/utilities/cryptography/issueBackupKey";
@@ -27,7 +29,11 @@ export default function PersonalSettings() {
const [backupKeyIssued, setBackupKeyIssued] = useState(false); const [backupKeyIssued, setBackupKeyIssued] = useState(false);
const [backupKeyError, setBackupKeyError] = useState(false); const [backupKeyError, setBackupKeyError] = useState(false);
const { t } = useTranslation(); const { t, lang } = useTranslation();
const changeLanguage = useCallback((code) => {
setLanguage(code);
}, []);
useEffect(async () => { useEffect(async () => {
let user = await getUser(); let user = await getUser();
@@ -108,6 +114,21 @@ export default function PersonalSettings() {
</div> */} </div> */}
</div> </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="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-row max-w-5xl justify-between items-center w-full">
<div className="flex flex-col justify-between w-full max-w-3xl"> <div className="flex flex-col justify-between w-full max-w-3xl">