From 621c37aa552c1d70fb80a2584dd4f14725e225b4 Mon Sep 17 00:00:00 2001 From: Bernt Christian Egeland Date: Wed, 21 Aug 2024 20:25:08 +0000 Subject: [PATCH] translations --- src/locales/en/common.json | 7 +++ src/locales/es/common.json | 7 +++ src/locales/fr/common.json | 7 +++ src/locales/no/common.json | 7 +++ src/locales/pl/common.json | 7 +++ src/locales/zh-tw/common.json | 7 +++ src/locales/zh/common.json | 7 +++ src/pages/auth/forgotPassword/reset/index.tsx | 52 ++++++++++++++++--- 8 files changed, 94 insertions(+), 7 deletions(-) diff --git a/src/locales/en/common.json b/src/locales/en/common.json index 6f112b28..ce0fb650 100644 --- a/src/locales/en/common.json +++ b/src/locales/en/common.json @@ -146,6 +146,8 @@ "emailPlaceholder": "mail@example.com", "password": "Password", "passwordPlaceholder": "Enter your password", + "confirmPassword": "Confirm Password", + "confirmPasswordPlaceholder": "Confirm your password", "forgotPassword": "Forgot your password?", "verify2FA": "Verify 2FA", "enter2FAcode": "Enter 2FA Code", @@ -175,6 +177,11 @@ "forgotPasswordMessage": "We will send you a reset link if the account exists", "backToLogin": "Back to Login" }, + "forgotReset": { + "forgotPasswordTitle": "Reset Password", + "forgotPasswordMessage": "Please enter your new password", + "backToLogin": "Back to Login" + }, "mfaRecovery": { "mfaRecoveryTitle": "2FA Recovery", "mfaRecoveryMessage": "We will send you instructions on how to recover your account", diff --git a/src/locales/es/common.json b/src/locales/es/common.json index 7cfc840c..851f4273 100644 --- a/src/locales/es/common.json +++ b/src/locales/es/common.json @@ -146,6 +146,8 @@ "emailPlaceholder": "correo@ejemplo.com", "password": "Contraseña", "passwordPlaceholder": "Introduce tu contraseña", + "confirmPassword": "Confirmar Contraseña", + "confirmPasswordPlaceholder": "Confirme su contraseña", "forgotPassword": "¿Olvidaste tu contraseña?", "verify2FA": "Verificar 2FA", "enter2FAcode": "Introduce el código 2FA", @@ -175,6 +177,11 @@ "forgotPasswordMessage": "Te enviaremos un enlace de restablecimiento si la cuenta existe", "backToLogin": "Volver al inicio de sesión" }, + "forgotReset": { + "forgotPasswordTitle": "Restablecer Contraseña", + "forgotPasswordMessage": "Por favor, ingrese su nueva contraseña", + "backToLogin": "Volver al Inicio de Sesión" + }, "mfaRecovery": { "mfaRecoveryTitle": "Recuperación de 2FA", "mfaRecoveryMessage": "Te enviaremos instrucciones sobre cómo recuperar tu cuenta", diff --git a/src/locales/fr/common.json b/src/locales/fr/common.json index fe2b3629..09d633b1 100644 --- a/src/locales/fr/common.json +++ b/src/locales/fr/common.json @@ -146,6 +146,8 @@ "emailPlaceholder": "mail@exemple.com", "password": "Mot de passe", "passwordPlaceholder": "Entrez votre mot de passe", + "confirmPassword": "Confirmer le Mot de Passe", + "confirmPasswordPlaceholder": "Confirmez votre mot de passe", "forgotPassword": "Mot de passe oublié ?", "verify2FA": "Vérifier 2FA", "enter2FAcode": "Entrez le code 2FA", @@ -175,6 +177,11 @@ "forgotPasswordMessage": "Nous vous enverrons un lien de réinitialisation si le compte existe", "backToLogin": "Retour à la connexion" }, + "forgotReset": { + "forgotPasswordTitle": "Réinitialiser le Mot de Passe", + "forgotPasswordMessage": "Veuillez entrer votre nouveau mot de passe", + "backToLogin": "Retour à la Connexion" + }, "mfaRecovery": { "mfaRecoveryTitle": "Récupération 2FA", "mfaRecoveryMessage": "Nous vous enverrons des instructions pour récupérer votre compte", diff --git a/src/locales/no/common.json b/src/locales/no/common.json index 2208dcbc..7755398b 100644 --- a/src/locales/no/common.json +++ b/src/locales/no/common.json @@ -146,6 +146,8 @@ "emailPlaceholder": "mail@eksempel.com", "password": "Passord", "passwordPlaceholder": "Skriv inn passordet ditt", + "confirmPassword": "Bekreft Passord", + "confirmPasswordPlaceholder": "Bekreft passordet ditt", "forgotPassword": "Glemt passordet ditt?", "verify2FA": "Bekreft 2FA", "enter2FAcode": "Skriv inn 2FA-koden", @@ -175,6 +177,11 @@ "forgotPasswordMessage": "Vi sender deg en tilbakestillingslenke hvis kontoen eksisterer", "backToLogin": "Tilbake til innlogging" }, + "forgotReset": { + "forgotPasswordTitle": "Tilbakestill Passord", + "forgotPasswordMessage": "Vennligst skriv inn ditt nye passord", + "backToLogin": "Tilbake til Innlogging" + }, "mfaRecovery": { "mfaRecoveryTitle": "Gjenoppretting av 2FA", "mfaRecoveryMessage": "Vi vil sende deg instruksjoner om hvordan du gjenoppretter kontoen din", diff --git a/src/locales/pl/common.json b/src/locales/pl/common.json index cd71e665..29efa9ca 100644 --- a/src/locales/pl/common.json +++ b/src/locales/pl/common.json @@ -146,6 +146,8 @@ "emailPlaceholder": "mail@przyklad.com", "password": "Hasło", "passwordPlaceholder": "Wpisz swoje hasło", + "confirmPassword": "Potwierdź Hasło", + "confirmPasswordPlaceholder": "Potwierdź swoje hasło", "forgotPassword": "Zapomniałeś hasła?", "verify2FA": "Zweryfikuj 2FA", "enter2FAcode": "Wpisz kod 2FA", @@ -175,6 +177,11 @@ "forgotPasswordMessage": "Wyślemy Ci link do resetowania, jeśli konto istnieje", "backToLogin": "Powrót do logowania" }, + "forgotReset": { + "forgotPasswordTitle": "Zresetuj Hasło", + "forgotPasswordMessage": "Proszę wprowadzić nowe hasło", + "backToLogin": "Powrót do Logowania" + }, "mfaRecovery": { "mfaRecoveryTitle": "Odzyskiwanie 2FA", "mfaRecoveryMessage": "Wyślemy Ci instrukcje, jak odzyskać swoje konto", diff --git a/src/locales/zh-tw/common.json b/src/locales/zh-tw/common.json index 09d0164c..5579aa4e 100644 --- a/src/locales/zh-tw/common.json +++ b/src/locales/zh-tw/common.json @@ -146,6 +146,8 @@ "emailPlaceholder": "mail@example.com", "password": "密碼", "passwordPlaceholder": "輸入您的密碼", + "confirmPassword": "確認密碼", + "confirmPasswordPlaceholder": "確認您的密碼", "forgotPassword": "忘記密碼?", "verify2FA": "驗證 2FA", "enter2FAcode": "輸入2FA代碼", @@ -175,6 +177,11 @@ "forgotPasswordMessage": "如果帳戶存在,我們會向您發送重置鏈接", "backToLogin": "返回登錄" }, + "forgotReset": { + "forgotPasswordTitle": "重設密碼", + "forgotPasswordMessage": "請輸入您的新密碼", + "backToLogin": "返回登入" + }, "mfaRecovery": { "mfaRecoveryTitle": "2FA恢復", "mfaRecoveryMessage": "我們將向您發送有關如何恢復您的帳戶的說明", diff --git a/src/locales/zh/common.json b/src/locales/zh/common.json index 371a797b..7f4547b9 100644 --- a/src/locales/zh/common.json +++ b/src/locales/zh/common.json @@ -146,6 +146,8 @@ "emailPlaceholder": "mail@example.com", "password": "密码", "passwordPlaceholder": "输入您的密码", + "confirmPassword": "确认密码", + "confirmPasswordPlaceholder": "确认您的密码", "forgotPassword": "忘记密码?", "verify2FA": "验证 2FA", "enter2FAcode": "输入2FA代码", @@ -175,6 +177,11 @@ "forgotPasswordMessage": "如果账户存在,我们将向您发送重置链接", "backToLogin": "返回登录" }, + "forgotReset": { + "forgotPasswordTitle": "重置密码", + "forgotPasswordMessage": "请输入您的新密码", + "backToLogin": "返回登录" + }, "mfaRecovery": { "mfaRecoveryTitle": "2FA恢复", "mfaRecoveryMessage": "我们将向您发送恢复帐户的说明", diff --git a/src/pages/auth/forgotPassword/reset/index.tsx b/src/pages/auth/forgotPassword/reset/index.tsx index 748c12e0..fed8e691 100644 --- a/src/pages/auth/forgotPassword/reset/index.tsx +++ b/src/pages/auth/forgotPassword/reset/index.tsx @@ -7,8 +7,13 @@ import Head from "next/head"; import { globalSiteTitle } from "~/utils/global"; import FormInput from "~/components/auth/formInput"; import FormSubmitButtons from "~/components/auth/formSubmitButton"; +import { useTranslations } from "next-intl"; +import { Session } from "next-auth"; +import { GetServerSideProps, GetServerSidePropsContext } from "next"; +import { getSession } from "next-auth/react"; const ForgotPassword = () => { + const t = useTranslations(); const router = useRouter(); const { token } = router.query; const [state, setState] = useState({ password: "", newPassword: "" }); @@ -85,17 +90,21 @@ const ForgotPassword = () => {
-

Reset Password

-

Please enter your new password

+

+ {t("authPages.forgotReset.forgotPasswordTitle")} +

+

+ {t("authPages.forgotReset.forgotPasswordMessage")} +

{ } /> { } />
- +
@@ -146,4 +155,33 @@ const ForgotPassword = () => { ); }; +interface Props { + auth?: Session["user"]; +} +export const getServerSideProps: GetServerSideProps = async ( + context: GetServerSidePropsContext, +) => { + const session = await getSession(context); + if (!session || !("user" in session) || !session.user) { + return { + props: { + messages: (await import(`~/locales/${context.locale}/common.json`)).default, + }, + }; + } + + if (session.user) { + return { + redirect: { + destination: "/network", + permanent: false, + }, + }; + } + + return { + props: { auth: session.user }, + }; +}; + export default ForgotPassword;