From 98b2ee29ef21322010f71a38bc0f665647c608f0 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Mon, 28 Feb 2022 20:54:32 -0800 Subject: [PATCH] Added language and theme settings. --- components/layout/Footer.module.css | 2 +- components/settings/LanguageSetting.js | 31 +++++++++++++ components/settings/ProfileSettings.js | 16 ++++++- components/settings/ThemeSetting.js | 25 +++++++++++ components/settings/ThemeSetting.module.css | 11 +++++ lang/ar-SA.json | 2 + lang/ca-ES.json | 2 + lang/cs-CZ.json | 2 + lang/da-DK.json | 2 + lang/de-DE.json | 2 + lang/el-GR.json | 2 + lang/en-GB.json | 2 + lang/en-US.json | 2 + lang/es-MX.json | 2 + lang/fa-IR.json | 2 + lang/fi-FI.json | 2 + lang/fo-FO.json | 2 + lang/fr-FR.json | 2 + lang/he-IL.json | 2 + lang/hi-IN.json | 2 + lang/hu-HU.json | 2 + lang/id-ID.json | 2 + lang/it-IT.json | 2 + lang/ja-JP.json | 2 + lang/ko-KR.json | 2 + lang/lt-LT.json | 2 + lang/mn-MN.json | 2 + lang/ms-MY.json | 2 + lang/nb-NO.json | 2 + lang/nl-NL.json | 2 + lang/pl-PL.json | 2 + lang/pt-BR.json | 2 + lang/pt-PT.json | 2 + lang/ro-RO.json | 2 + lang/ru-RU.json | 2 + lang/sk-SK.json | 2 + lang/sl-SI.json | 2 + lang/sv-SE.json | 2 + lang/ta-IN.json | 2 + lang/tr-TR.json | 2 + lang/uk-UA.json | 2 + lang/ur-PK.json | 2 + lang/vi-VN.json | 2 + lang/zh-CN.json | 2 + lang/zh-TW.json | 2 + public/messages/ar-SA.json | 12 ++++++ public/messages/ca-ES.json | 12 ++++++ public/messages/cs-CZ.json | 12 ++++++ public/messages/da-DK.json | 12 ++++++ public/messages/de-DE.json | 12 ++++++ public/messages/el-GR.json | 12 ++++++ public/messages/en-GB.json | 12 ++++++ public/messages/en-US.json | 12 ++++++ public/messages/es-MX.json | 12 ++++++ public/messages/fa-IR.json | 12 ++++++ public/messages/fi-FI.json | 12 ++++++ public/messages/fo-FO.json | 12 ++++++ public/messages/fr-FR.json | 12 ++++++ public/messages/he-IL.json | 12 ++++++ public/messages/hi-IN.json | 12 ++++++ public/messages/hu-HU.json | 12 ++++++ public/messages/id-ID.json | 12 ++++++ public/messages/it-IT.json | 48 +++++++++++++-------- public/messages/ja-JP.json | 12 ++++++ public/messages/ko-KR.json | 12 ++++++ public/messages/lt-LT.json | 12 ++++++ public/messages/mn-MN.json | 12 ++++++ public/messages/ms-MY.json | 12 ++++++ public/messages/nb-NO.json | 12 ++++++ public/messages/nl-NL.json | 12 ++++++ public/messages/pl-PL.json | 12 ++++++ public/messages/pt-BR.json | 12 ++++++ public/messages/pt-PT.json | 12 ++++++ public/messages/ro-RO.json | 12 ++++++ public/messages/ru-RU.json | 12 ++++++ public/messages/sk-SK.json | 12 ++++++ public/messages/sl-SI.json | 12 ++++++ public/messages/sv-SE.json | 12 ++++++ public/messages/ta-IN.json | 12 ++++++ public/messages/tr-TR.json | 12 ++++++ public/messages/uk-UA.json | 12 ++++++ public/messages/ur-PK.json | 12 ++++++ public/messages/vi-VN.json | 12 ++++++ public/messages/zh-CN.json | 12 ++++++ public/messages/zh-TW.json | 12 ++++++ styles/index.css | 8 ++-- 86 files changed, 664 insertions(+), 25 deletions(-) create mode 100644 components/settings/LanguageSetting.js create mode 100644 components/settings/ThemeSetting.js create mode 100644 components/settings/ThemeSetting.module.css diff --git a/components/layout/Footer.module.css b/components/layout/Footer.module.css index 1a7baaa8..c484d7f5 100644 --- a/components/layout/Footer.module.css +++ b/components/layout/Footer.module.css @@ -4,7 +4,7 @@ align-items: center; font-size: var(--font-size-small); text-align: center; - margin: 20px 0; + margin: 30px 0; } .version { diff --git a/components/settings/LanguageSetting.js b/components/settings/LanguageSetting.js new file mode 100644 index 00000000..294a92a3 --- /dev/null +++ b/components/settings/LanguageSetting.js @@ -0,0 +1,31 @@ +import React from 'react'; +import { FormattedMessage } from 'react-intl'; +import DropDown from 'components/common/DropDown'; +import Button from 'components/common/Button'; +import useLocale from 'hooks/useLocale'; +import { DEFAULT_LOCALE } from 'lib/constants'; +import styles from './TimezoneSetting.module.css'; +import { languages } from '../../lib/lang'; + +export default function LanguageSetting() { + const { locale, saveLocale } = useLocale(); + const options = Object.keys(languages).map(key => ({ ...languages[key], value: key })); + + function handleReset() { + saveLocale(DEFAULT_LOCALE); + } + + return ( + <> + + + + ); +} diff --git a/components/settings/ProfileSettings.js b/components/settings/ProfileSettings.js index 798ef4bf..14c766a5 100644 --- a/components/settings/ProfileSettings.js +++ b/components/settings/ProfileSettings.js @@ -11,11 +11,13 @@ import styles from './ProfileSettings.module.css'; import DateRangeSetting from './DateRangeSetting'; import useEscapeKey from 'hooks/useEscapeKey'; import useUser from 'hooks/useUser'; +import LanguageSetting from './LanguageSetting'; +import ThemeSetting from './ThemeSetting'; export default function ProfileSettings() { const { user } = useUser(); const [changePassword, setChangePassword] = useState(false); - const [message, setMessage] = useState(); + const [message, setMessage] = useState(null); function handleSave() { setChangePassword(false); @@ -59,6 +61,18 @@ export default function ProfileSettings() {
+
+ +
+
+ +
+
+ +
+
+ +
{changePassword && ( +