注册登陆页面增加多语言支持

This commit is contained in:
jingrow 2025-12-29 19:05:24 +08:00
parent d05f2215b2
commit 9cf903a880
2 changed files with 116 additions and 66 deletions

View File

@ -11,7 +11,7 @@
<!-- 2FA 部分 --> <!-- 2FA 部分 -->
<template v-if="is2FA"> <template v-if="is2FA">
<FormControl <FormControl
label="来自您的身份验证应用的2FA代码" :label="$t('2FA code from your authenticator app')"
placeholder="123456" placeholder="123456"
v-model="twoFactorCode" v-model="twoFactorCode"
required required
@ -31,7 +31,7 @@
}) })
" "
> >
验证 {{ $t('Verify') }}
</Button> </Button>
<ErrorMessage <ErrorMessage
class="mt-2" class="mt-2"
@ -42,7 +42,7 @@
<!-- 忘记密码部分 --> <!-- 忘记密码部分 -->
<template v-else-if="hasForgotPassword"> <template v-else-if="hasForgotPassword">
<FormControl <FormControl
label="邮箱" :label="$t('Email')"
type="email" type="email"
placeholder="email@example.com" placeholder="email@example.com"
autocomplete="email" autocomplete="email"
@ -57,21 +57,21 @@
query: { ...$route.query, forgot: undefined }, query: { ...$route.query, forgot: undefined },
}" }"
> >
我记得我的密码 {{ $t('I remember my password') }}
</router-link> </router-link>
<Button <Button
class="mt-4" class="mt-4"
:loading="$resources.resetPassword.loading" :loading="$resources.resetPassword.loading"
variant="solid" variant="solid"
> >
重置密码 {{ $t('Reset Password') }}
</Button> </Button>
</template> </template>
<!-- 登录部分 --> <!-- 登录部分 -->
<template v-else-if="isLogin"> <template v-else-if="isLogin">
<FormControl <FormControl
label="用户名或邮箱" :label="$t('Username or Email')"
placeholder="email@example.com" placeholder="email@example.com"
autocomplete="email" autocomplete="email"
v-model="email" v-model="email"
@ -83,7 +83,7 @@
<template v-if="!isOauthLogin && !useEmail"> <template v-if="!isOauthLogin && !useEmail">
<FormControl <FormControl
class="mt-4" class="mt-4"
label="密码" :label="$t('Password')"
type="password" type="password"
placeholder="•••••" placeholder="•••••"
v-model="password" v-model="password"
@ -99,7 +99,7 @@
query: { ...$route.query, forgot: 1 }, query: { ...$route.query, forgot: 1 },
}" }"
> >
忘记密码 {{ $t('Forgot Password?') }}
</router-link> </router-link>
</div> </div>
<Button <Button
@ -108,7 +108,7 @@
:loading="$session.login.loading" :loading="$session.login.loading"
type="submit" type="submit"
> >
登录 {{ $t('Log In') }}
</Button> </Button>
</template> </template>
@ -118,7 +118,7 @@
<template v-if="otpSent"> <template v-if="otpSent">
<FormControl <FormControl
class="mt-4" class="mt-4"
label="验证码" :label="$t('Verification Code')"
placeholder="123456" placeholder="123456"
v-model="otp" v-model="otp"
required required
@ -130,7 +130,7 @@
variant="solid" variant="solid"
@click="verifyOTPAndLogin" @click="verifyOTPAndLogin"
> >
登陆 {{ $t('Log In') }}
</Button> </Button>
<Button <Button
class="w-full" class="w-full"
@ -139,10 +139,10 @@
:disabled="otpResendCountdown > 0" :disabled="otpResendCountdown > 0"
@click="$resources.sendOTP.submit()" @click="$resources.sendOTP.submit()"
> >
重新发送验证码 {{ $t('Resend Verification Code') }}
{{ {{
otpResendCountdown > 0 otpResendCountdown > 0
? `${otpResendCountdown} 秒后` ? ` ${$t('in')} ${otpResendCountdown} ${$t('seconds')}`
: '' : ''
}} }}
</Button> </Button>
@ -157,7 +157,7 @@
variant="solid" variant="solid"
@click="$resources.sendOTP.submit()" @click="$resources.sendOTP.submit()"
> >
发送验证码 {{ $t('Send Verification Code') }}
</Button> </Button>
</template> </template>
</template> </template>
@ -165,7 +165,7 @@
<!-- OAuth 验证 --> <!-- OAuth 验证 -->
<template v-else> <template v-else>
<Button class="mt-4" variant="solid"> <Button class="mt-4" variant="solid">
使用 {{ oauthProviderName }} 登录 {{ $t('Log in with') }} {{ oauthProviderName }}
</Button> </Button>
</template> </template>
@ -184,15 +184,15 @@
<!-- 注册部分 --> <!-- 注册部分 -->
<template v-else> <template v-else>
<FormControl <FormControl
label="用户名" :label="$t('Username')"
type="text" type="text"
placeholder="设置用户名" :placeholder="$t('Set username')"
v-model="username" v-model="username"
autocomplete="username" autocomplete="username"
required required
/> />
<FormControl <FormControl
label="邮箱 (可选)" :label="$t('Email (optional)')"
type="email" type="email"
placeholder="email@example.com" placeholder="email@example.com"
autocomplete="email" autocomplete="email"
@ -200,9 +200,9 @@
v-model="email" v-model="email"
/> />
<FormControl <FormControl
label="手机号" :label="$t('Phone Number')"
type="tel" type="tel"
placeholder="请输入您的手机号码" :placeholder="$t('Please enter your phone number')"
class="mt-4" class="mt-4"
v-model="phoneNumber" v-model="phoneNumber"
autocomplete="tel" autocomplete="tel"
@ -210,23 +210,23 @@
@blur="validatePhoneNumber" @blur="validatePhoneNumber"
/> />
<div v-if="phoneNumberFormatError" class="mt-2 text-sm text-red-600"> <div v-if="phoneNumberFormatError" class="mt-2 text-sm text-red-600">
请输入正确的手机号码格式 {{ $t('Please enter a valid phone number format') }}
</div> </div>
<FormControl <FormControl
label="密码" :label="$t('Password')"
type="password" type="password"
placeholder="设置登录密码" :placeholder="$t('Set login password')"
class="mt-4" class="mt-4"
v-model="signupPassword" v-model="signupPassword"
autocomplete="new-password" autocomplete="new-password"
required required
/> />
<div class="mt-1 text-sm text-gray-600"> <div class="mt-1 text-sm text-gray-600">
密码必须至少8个字符并包含大小写字母和数字 {{ $t('Password must be at least 8 characters and contain uppercase and lowercase letters and numbers') }}
</div> </div>
<div class="mt-2" v-if="signupPassword"> <div class="mt-2" v-if="signupPassword">
<div class="flex items-center"> <div class="flex items-center">
<div class="text-sm w-20">密码强度:</div> <div class="text-sm w-20">{{ $t('Password Strength') }}:</div>
<div class="flex-1 bg-gray-200 rounded-full h-2"> <div class="flex-1 bg-gray-200 rounded-full h-2">
<div <div
class="h-2 rounded-full transition-all" class="h-2 rounded-full transition-all"
@ -237,16 +237,16 @@
</div> </div>
</div> </div>
<FormControl <FormControl
label="确认密码" :label="$t('Confirm Password')"
type="password" type="password"
placeholder="再次输入密码" :placeholder="$t('Enter password again')"
class="mt-4" class="mt-4"
v-model="confirmPassword" v-model="confirmPassword"
autocomplete="new-password" autocomplete="new-password"
required required
/> />
<div v-if="passwordMismatch" class="mt-2 text-sm text-red-600"> <div v-if="passwordMismatch" class="mt-2 text-sm text-red-600">
两次输入的密码不一致 {{ $t('Passwords do not match') }}
</div> </div>
<Button <Button
class="mt-4" class="mt-4"
@ -255,7 +255,7 @@
type="submit" type="submit"
:disabled="(passwordMismatch && confirmPassword) || phoneNumberFormatError" :disabled="(passwordMismatch && confirmPassword) || phoneNumberFormatError"
> >
注册 {{ $t('Sign Up') }}
</Button> </Button>
</template> </template>
@ -270,7 +270,7 @@
<span <span
class="relative bg-white px-2 text-sm font-medium leading-8 text-gray-800" class="relative bg-white px-2 text-sm font-medium leading-8 text-gray-800"
> >
{{ $t('Or') }}
</span> </span>
</div> </div>
</div> </div>
@ -281,14 +281,14 @@
@click="switchToEmailLogin" @click="switchToEmailLogin"
icon-left="mail" icon-left="mail"
> >
使用邮箱验证码登陆 {{ $t('Log in with email verification code') }}
</Button> </Button>
<Button <Button
v-else-if="isLogin && useEmail" v-else-if="isLogin && useEmail"
@click="switchToPasswordLogin" @click="switchToPasswordLogin"
icon-left="key" icon-left="key"
> >
使用密码登陆 {{ $t('Log in with password') }}
</Button> </Button>
</div> </div>
<div <div
@ -304,8 +304,8 @@
> >
{{ {{
$route.name == 'Login' $route.name == 'Login'
? '没有账户?创建一个账户。' ? $t('Don\'t have an account? Create one.')
: '已有账户?登录。' : $t('Already have an account? Log in.')
}} }}
</router-link> </router-link>
</div> </div>
@ -314,7 +314,7 @@
<div v-else-if="otpRequested"> <div v-else-if="otpRequested">
<form class="flex flex-col"> <form class="flex flex-col">
<FormControl <FormControl
label="邮箱" :label="$t('Email')"
type="email" type="email"
placeholder="email@example.com" placeholder="email@example.com"
autocomplete="email" autocomplete="email"
@ -322,7 +322,7 @@
required required
/> />
<FormControl <FormControl
label="验证码" :label="$t('Verification Code')"
type="text" type="text"
class="mt-4" class="mt-4"
placeholder="123456" placeholder="123456"
@ -340,7 +340,7 @@
:loading="$resources.verifyOTP.loading" :loading="$resources.verifyOTP.loading"
@click="$resources.verifyOTP.submit()" @click="$resources.verifyOTP.submit()"
> >
验证 {{ $t('Verify') }}
</Button> </Button>
<Button <Button
class="mt-2" class="mt-2"
@ -349,10 +349,10 @@
@click="$resources.resendOTP.submit()" @click="$resources.resendOTP.submit()"
:disabled="otpResendCountdown > 0" :disabled="otpResendCountdown > 0"
> >
重新发送验证码 {{ $t('Resend Verification Code') }}
{{ {{
otpResendCountdown > 0 otpResendCountdown > 0
? `${otpResendCountdown} 秒后` ? ` ${$t('in')} ${otpResendCountdown} ${$t('seconds')}`
: '' : ''
}} }}
</Button> </Button>
@ -367,8 +367,8 @@
> >
{{ {{
$route.name == 'Login' $route.name == 'Login'
? '新用户?创建一个新账户。' ? $t('New user? Create a new account.')
: '已有账户?登录。' : $t('Already have an account? Log in.')
}} }}
</router-link> </router-link>
</div> </div>
@ -378,9 +378,9 @@
v-else-if="resetPasswordEmailSent" v-else-if="resetPasswordEmailSent"
> >
<p> <p>
我们已向 {{ $t('We have sent an email to') }}
<span class="font-semibold">{{ email }}</span <span class="font-semibold">{{ email }}</span
>发送了一封邮件请点击收到的链接重置您的密码 >{{ $t('. Please click on the link received to reset your password.') }}
</p> </p>
</div> </div>
</template> </template>
@ -401,7 +401,7 @@
<div <div
class="mt-2 flex w-full items-center justify-center text-sm text-gray-600" class="mt-2 flex w-full items-center justify-center text-sm text-gray-600"
> >
今果 Jingrow 提供支持 {{ $t('Powered by Jingrow') }}
</div> </div>
</template> </template>
</LoginBox> </LoginBox>
@ -463,7 +463,7 @@ export default {
this.account_request = account_request; this.account_request = account_request;
this.otpRequested = true; this.otpRequested = true;
this.otpResendCountdown = 30; this.otpResendCountdown = 30;
toast.success('验证码已发送至您的邮箱'); toast.success(this.$t('Verification code has been sent to your email'));
}, },
onError: (error) => { onError: (error) => {
if (error?.exc_type !== 'ValidationError') { if (error?.exc_type !== 'ValidationError') {
@ -514,11 +514,11 @@ export default {
onSuccess() { onSuccess() {
this.otp = ''; this.otp = '';
this.otpResendCountdown = 30; this.otpResendCountdown = 30;
toast.success('验证码已发送至您的邮箱'); toast.success(this.$t('Verification code has been sent to your email'));
}, },
onError(err) { onError(err) {
toast.error( toast.error(
getToastErrorMessage(err, '验证码重发失败'), getToastErrorMessage(err, this.$t('Failed to resend verification code')),
); );
}, },
}; };
@ -532,11 +532,11 @@ export default {
onSuccess() { onSuccess() {
this.otpSent = true; this.otpSent = true;
this.otpResendCountdown = 30; this.otpResendCountdown = 30;
toast.success('验证码已发送至您的邮箱'); toast.success(this.$t('Verification code has been sent to your email'));
}, },
onError(err) { onError(err) {
toast.error( toast.error(
getToastErrorMessage(err, '验证码发送失败'), getToastErrorMessage(err, this.$t('Failed to send verification code')),
); );
}, },
}; };
@ -615,7 +615,7 @@ export default {
}, },
onSuccess(res) { onSuccess(res) {
if (res && res.success === false) { if (res && res.success === false) {
toast.error(res.message || '注册失败,请检查您的信息'); toast.error(res.message || this.$t('Sign up failed, please check your information'));
return; return;
} }
@ -630,7 +630,7 @@ export default {
onError(err) { onError(err) {
const errorMessage = err?.messages?.length const errorMessage = err?.messages?.length
? err.messages.join('\n') ? err.messages.join('\n')
: (err?.message || '注册失败,请检查您的信息'); : (err?.message || this.$t('Sign up failed, please check your information'));
toast.error(errorMessage); toast.error(errorMessage);
}, },
}; };
@ -661,27 +661,27 @@ export default {
this.checkTwoFactorAndResetPassword(); this.checkTwoFactorAndResetPassword();
} else { } else {
if (!this.username) { if (!this.username) {
toast.error('用户名不能为空'); toast.error(this.$t('Username cannot be empty'));
return; return;
} }
if (!this.phoneNumber) { if (!this.phoneNumber) {
toast.error('手机号不能为空'); toast.error(this.$t('Phone number cannot be empty'));
return; return;
} }
if (!this.isPhoneNumberValid) { if (!this.isPhoneNumberValid) {
toast.error('请输入正确的手机号码格式'); toast.error(this.$t('Please enter a valid phone number format'));
return; return;
} }
if (!this.signupPassword) { if (!this.signupPassword) {
toast.error('密码不能为空'); toast.error(this.$t('Password cannot be empty'));
return; return;
} }
if (this.signupPassword !== this.confirmPassword) { if (this.signupPassword !== this.confirmPassword) {
toast.error('两次输入的密码不一致'); toast.error(this.$t('Passwords do not match'));
return; return;
} }
if (!this.isPasswordValid) { if (!this.isPasswordValid) {
toast.error('密码必须至少8个字符并包含大小写字母和数字'); toast.error(this.$t('Password must be at least 8 characters and contain uppercase and lowercase letters and numbers'));
return; return;
} }
this.$resources.signupWithUsername.submit(); this.$resources.signupWithUsername.submit();
@ -879,17 +879,17 @@ export default {
}, },
title() { title() {
if (this.hasForgotPassword) { if (this.hasForgotPassword) {
return '重置密码'; return this.$t('Reset Password');
} else if (this.isLogin) { } else if (this.isLogin) {
if (this.saasProduct) { if (this.saasProduct) {
return `登录您的账户以开始使用 ${this.saasProduct.title}`; return this.$t('Log in to your account to start using {product}', { product: this.saasProduct.title });
} }
return '登录您的账户'; return this.$t('Log in to your account');
} else { } else {
if (this.saasProduct) { if (this.saasProduct) {
return `注册以创建您的 ${this.saasProduct.title} 站点`; return this.$t('Sign up to create your {product} site', { product: this.saasProduct.title });
} }
return '创建新账户'; return this.$t('Create New Account');
} }
}, },
useEmail() { useEmail() {
@ -925,10 +925,10 @@ export default {
return 'bg-green-500'; return 'bg-green-500';
}, },
passwordStrengthText() { passwordStrengthText() {
if (this.passwordStrength < 40) return '弱'; if (this.passwordStrength < 40) return this.$t('Weak');
if (this.passwordStrength < 60) return '一般'; if (this.passwordStrength < 60) return this.$t('Fair');
if (this.passwordStrength < 80) return '强'; if (this.passwordStrength < 80) return this.$t('Strong');
return '非常强'; return this.$t('Very Strong');
}, },
passwordStrengthTextClass() { passwordStrengthTextClass() {
if (this.passwordStrength < 40) return 'text-red-500'; if (this.passwordStrength < 40) return 'text-red-500';

View File

@ -1084,3 +1084,53 @@ Currently Active,当前激活,
Switch,切换, Switch,切换,
Select Team,选择团队, Select Team,选择团队,
This feature is only available for system users,此功能仅对系统用户可用, This feature is only available for system users,此功能仅对系统用户可用,
2FA code from your authenticator app,来自您的身份验证应用的2FA代码,
Verify,验证,
I remember my password,我记得我的密码,
Username or Email,用户名或邮箱,
Forgot Password?,忘记密码?,
Log In,登录,
Verification Code,验证码,
Resend Verification Code,重新发送验证码,
in,,
seconds,秒后,
Send Verification Code,发送验证码,
Log in with,使用,
Username,用户名,
Set username,设置用户名,
Email (optional),邮箱 (可选),
Phone Number,手机号,
Please enter your phone number,请输入您的手机号码,
Please enter a valid phone number format,请输入正确的手机号码格式,
Set login password,设置登录密码,
Password must be at least 8 characters and contain uppercase and lowercase letters and numbers,密码必须至少8个字符并包含大小写字母和数字,
Password Strength,密码强度,
Confirm Password,确认密码,
Enter password again,再次输入密码,
Passwords do not match,两次输入的密码不一致,
Sign Up,注册,
Or,,
Log in with email verification code,使用邮箱验证码登陆,
Log in with password,使用密码登陆,
Don't have an account? Create one.,没有账户?创建一个账户。,
Already have an account? Log in.,已有账户?登录。,
New user? Create a new account.,新用户?创建一个新账户。,
We have sent an email to,我们已向,
. Please click on the link received to reset your password.,发送了一封邮件。请点击收到的链接重置您的密码。,
Powered by Jingrow,由 今果 Jingrow 提供支持,
Verification code has been sent to your email,验证码已发送至您的邮箱,
Failed to resend verification code,验证码重发失败,
Failed to send verification code,验证码发送失败,
Sign up failed, please check your information,注册失败,请检查您的信息,
Username cannot be empty,用户名不能为空,
Phone number cannot be empty,手机号不能为空,
Password cannot be empty,密码不能为空,
Reset Password,重置密码,
Log in to your account,登录您的账户,
Log in to your account to start using {product},登录您的账户以开始使用 {product},
Sign up to create your {product} site,注册以创建您的 {product} 站点,
Create New Account,创建新账户,
Weak,,
Fair,一般,
Strong,,
Very Strong,非常强,

Can't render this file because it has a wrong number of fields in line 390.