From b289121bf84c611c6cacf325bcb879702fbe3c6c Mon Sep 17 00:00:00 2001 From: hailin Date: Thu, 17 Apr 2025 20:45:56 +0800 Subject: [PATCH] . --- app/[locale]/login/page.tsx | 29 ++++++++++++++++------------- public/locales/en/translation.json | 16 +++++++++++++++- public/locales/zh/translation.json | 16 +++++++++++++++- 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/app/[locale]/login/page.tsx b/app/[locale]/login/page.tsx index 411aa68..0659a54 100644 --- a/app/[locale]/login/page.tsx +++ b/app/[locale]/login/page.tsx @@ -1,3 +1,4 @@ +import { useTranslation } from 'next-i18next' import { Brand } from "@/components/ui/brand" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" @@ -19,6 +20,8 @@ export default async function Login({ }: { searchParams: { message: string } }) { + const { t } = useTranslation() + const cookieStore = cookies() const supabase = createServerClient( process.env.NEXT_PUBLIC_SUPABASE_URL!, @@ -75,7 +78,7 @@ export default async function Login({ if (!homeWorkspace) { throw new Error( - homeWorkspaceError?.message || "An unexpected error occurred" + homeWorkspaceError?.message || t('login.errorUnexpected') ) } @@ -116,7 +119,7 @@ export default async function Login({ const emailMatch = emailWhitelist?.includes(email) if (!domainMatch && !emailMatch) { return redirect( - `/login?message=Email ${email} is not allowed to sign up.` + `/login?message=${t('login.emailNotAllowed', { email })}` ) } } @@ -138,10 +141,10 @@ export default async function Login({ return redirect(`/login?message=${error.message}`) } - return redirect("/setup") - // USE IF YOU WANT TO SEND EMAIL VERIFICATION, ALSO CHANGE TOML FILE // return redirect("/login?message=Check email to continue sign in process") + + return redirect("/setup") } const handleResetPassword = async (formData: FormData) => { @@ -160,7 +163,7 @@ export default async function Login({ return redirect(`/login?message=${error.message}`) } - return redirect("/login?message=Check email to reset password") + return redirect("/login?message=" + t('login.passwordResetMessage')) } return ( @@ -172,43 +175,43 @@ export default async function Login({ - Login + {t('login.loginButton')} - Sign Up + {t('login.signUpButton')}
- Forgot your password? + {t('login.forgotPassword')}
diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 6dc6047..a2665ad 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -7,5 +7,19 @@ "Enter API keys for each service you'd like to use.": "Enter API keys for each service you'd like to use.", "Set API Keys (optional)": "Set API Keys (optional)", "You are all set up!": "You are all set up!", - "Setup Complete": "Setup Complete" + "Setup Complete": "Setup Complete", + + "login": { + "email": "Email", + "emailPlaceholder": "you@example.com", + "password": "Password", + "passwordPlaceholder": "••••••••", + "loginButton": "Login", + "signUpButton": "Sign Up", + "forgotPassword": "Forgot your password?", + "reset": "Reset", + "emailNotAllowed": "Email {{email}} is not allowed to sign up.", + "passwordResetMessage": "Check email to reset password", + "errorUnexpected": "An unexpected error occurred" + } } diff --git a/public/locales/zh/translation.json b/public/locales/zh/translation.json index 718b1f1..44166c9 100644 --- a/public/locales/zh/translation.json +++ b/public/locales/zh/translation.json @@ -7,5 +7,19 @@ "Enter API keys for each service you'd like to use.": "输入您希望使用的每个服务的 API 密钥。", "Set API Keys (optional)": "设置 API 密钥(可选)", "You are all set up!": "设置完成!", - "Setup Complete": "设置完成" + "Setup Complete": "设置完成", + + "login": { + "email": "电子邮件", + "emailPlaceholder": "you@example.com", + "password": "密码", + "passwordPlaceholder": "••••••••", + "loginButton": "登录", + "signUpButton": "注册", + "forgotPassword": "忘记密码?", + "reset": "重置", + "emailNotAllowed": "邮箱 {{email}} 不允许注册。", + "passwordResetMessage": "请检查邮箱以重置密码", + "errorUnexpected": "发生了意外错误" + } }