feat(login): translations (#10849)

# Which Problems Are Solved

Replace this example text with a concise list of problems that this PR
solves.
For example:
- password complexity requirements have hardcoded English text
- password, loginname, register and verify components have hardcoded
Engilsh error messages/alerts

# How the Problems Are Solved

Replace this example text with a concise list of changes that this PR
introduces.
For example:
- adds i18n for password complexity requirements
- adds i18n for password, loginname, register and verify components
error messages/alerts

# Additional Changes

- small change in code/styles for icons in PasswordComplexity to make
sure that icons keep size

# Additional Context

N.A

---------

Co-authored-by: Adam Kida <[email protected]>
This commit is contained in:
Max Peintner
2025-10-09 11:11:03 +02:00
committed by GitHub
co-authored by Adam Kida
parent 794054c075
commit 64e14de091
22 changed files with 972 additions and 195 deletions
+11 -8
View File
@@ -25,6 +25,7 @@ import { loadMostRecentSession } from "../session";
import { checkMFAFactors } from "../verify-helper";
import { createSessionAndUpdateCookie } from "./cookie";
import { getOriginalHostWithProtocol } from "./host";
import { getTranslations } from "next-intl/server";
export async function verifyTOTP(code: string, loginName?: string, organization?: string) {
const _headers = await headers();
@@ -59,6 +60,7 @@ type VerifyUserByEmailCommand = {
};
export async function sendVerification(command: VerifyUserByEmailCommand) {
const t = await getTranslations("verify");
const _headers = await headers();
const { serviceUrl } = getServiceUrlFromHeaders(_headers);
@@ -69,7 +71,7 @@ export async function sendVerification(command: VerifyUserByEmailCommand) {
verificationCode: command.code,
}).catch((error) => {
console.warn(error);
return { error: "Could not verify invite" };
return { error: t("errors.couldNotVerifyInvite") };
})
: await verifyEmail({
serviceUrl,
@@ -77,7 +79,7 @@ export async function sendVerification(command: VerifyUserByEmailCommand) {
verificationCode: command.code,
}).catch((error) => {
console.warn(error);
return { error: "Could not verify email" };
return { error: t("errors.couldNotVerifyEmail") };
});
if ("error" in verifyResponse) {
@@ -85,7 +87,7 @@ export async function sendVerification(command: VerifyUserByEmailCommand) {
}
if (!verifyResponse) {
return { error: "Could not verify" };
return { error: t("errors.couldNotVerify") };
}
let session: Session | undefined;
@@ -95,7 +97,7 @@ export async function sendVerification(command: VerifyUserByEmailCommand) {
});
if (!userResponse || !userResponse.user) {
return { error: "Could not load user" };
return { error: t("errors.couldNotLoadUser") };
}
const user = userResponse.user;
@@ -126,7 +128,7 @@ export async function sendVerification(command: VerifyUserByEmailCommand) {
});
if (!authMethodResponse || !authMethodResponse.authMethodTypes) {
return { error: "Could not load possible authenticators" };
return { error: t("errors.couldNotLoadAuthenticators") };
}
// if no authmethods are found on the user, redirect to set one up
@@ -148,7 +150,7 @@ export async function sendVerification(command: VerifyUserByEmailCommand) {
}
if (!session) {
return { error: "Could not create session" };
return { error: t("errors.couldNotCreateSession") };
}
const params = new URLSearchParams({
@@ -249,6 +251,7 @@ type resendVerifyEmailCommand = {
};
export async function resendVerification(command: resendVerifyEmailCommand) {
const t = await getTranslations("verify");
const _headers = await headers();
const { serviceUrl } = getServiceUrlFromHeaders(_headers);
const hostWithProtocol = await getOriginalHostWithProtocol();
@@ -264,9 +267,9 @@ export async function resendVerification(command: resendVerifyEmailCommand) {
(command.requestId ? `&requestId=${command.requestId}` : ""),
}).catch((error) => {
if (error.code === 9) {
return { error: "User is already verified!" };
return { error: t("errors.userAlreadyVerified") };
}
return { error: "Could not resend invite" };
return { error: t("errors.couldNotResendInvite") };
})
: zitadelSendEmailCode({
userId: command.userId,