Skip to content

Commit ae9357d

Browse files
Merge pull request #237 from import-ai/fix/i18n
fix(i18n): Add i18n support for otp
2 parents b6e1efc + 265434b commit ae9357d

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/auth/otp.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ export class OtpService {
7272
if (record.count >= this.RATE_LIMIT_MAX) {
7373
const remainingMinutes = Math.ceil((record.resetAt - now) / 60000);
7474
throw new BadRequestException(
75-
`Too many OTP requests. Please try again in ${remainingMinutes} minutes.`,
75+
this.i18n.t('auth.errors.tooManyOtpRequests', {
76+
args: { minutes: remainingMinutes },
77+
}),
7678
);
7779
}
7880

src/i18n/en/auth.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"invalidVerificationCode": "Invalid or expired verification code",
2525
"invalidVerificationCodeWithAttempts": "Invalid verification code. {remaining} attempts remaining.",
2626
"expiredVerificationCode": "Verification code has expired",
27-
"tooManyAttempts": "Too many failed attempts. Please request a new code."
27+
"tooManyAttempts": "Too many failed attempts. Please request a new code.",
28+
"tooManyOtpRequests": "Too many OTP requests. Please try again in {minutes} minutes."
2829
},
2930
"providers": {
3031
"google": "Google",

src/i18n/zh/auth.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"invalidVerificationCode": "验证码无效或已过期",
2525
"invalidVerificationCodeWithAttempts": "验证码无效。还剩 {remaining} 次尝试机会。",
2626
"expiredVerificationCode": "验证码已过期",
27-
"tooManyAttempts": "尝试次数过多,请重新获取验证码。"
27+
"tooManyAttempts": "尝试次数过多,请重新获取验证码。",
28+
"tooManyOtpRequests": "验证码请求过多,请在 {minutes} 分钟后重试。"
2829
},
2930
"providers": {
3031
"google": "Google",

0 commit comments

Comments
 (0)