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
@@ -5,6 +5,8 @@ import {
upperCaseValidator,
} from "@/helpers/validators";
import { PasswordComplexitySettings } from "@zitadel/proto/zitadel/settings/v2/password_settings_pb";
import { useTranslations } from "next-intl";
import { Translated } from "@/components/translated";
type Props = {
passwordComplexitySettings: PasswordComplexitySettings;
@@ -12,42 +14,55 @@ type Props = {
equals: boolean;
};
const check = (
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.5}
stroke="currentColor"
className="las la-check mr-2 h-6 w-6 text-lg text-green-500 dark:text-green-500"
role="img"
>
<title>Matches</title>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M4.5 12.75l6 6 9-13.5"
/>
</svg>
);
const cross = (
<svg
className="las la-times mr-2 h-6 w-6 text-lg text-warn-light-500 dark:text-warn-dark-500"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.5}
stroke="currentColor"
role="img"
>
<title>Doesn&apos;t match</title>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M6 18L18 6M6 6l12 12"
/>
</svg>
);
function CheckIcon({ title }: { title: string }) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.5}
stroke="currentColor"
className="las la-check mr-2 h-6 w-6 flex-none text-lg text-green-500 dark:text-green-500"
role="img"
>
<title>{title}</title>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M4.5 12.75l6 6 9-13.5"
/>
</svg>
);
}
function CrossIcon({ title }: { title: string }) {
return (
<svg
className="las la-times mr-2 h-6 w-6 flex-none text-lg text-warn-light-500 dark:text-warn-dark-500"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.5}
stroke="currentColor"
role="img"
>
<title>{title}</title>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M6 18L18 6M6 6l12 12"
/>
</svg>
);
}
function renderIcon(matched: boolean, t: ReturnType<typeof useTranslations>) {
return matched ? (
<CheckIcon title={t("complexity.matches")} />
) : (
<CrossIcon title={t("complexity.doesNotMatch")} />
);
}
const desc =
"text-14px leading-4 text-input-light-label dark:text-input-dark-label";
@@ -56,6 +71,7 @@ export function PasswordComplexity({
password,
equals,
}: Props) {
const t = useTranslations("password");
const hasMinLength = password?.length >= passwordComplexitySettings.minLength;
const hasSymbol = symbolValidator(password);
const hasNumber = numberValidator(password);
@@ -66,33 +82,47 @@ export function PasswordComplexity({
<div className="mb-4 grid grid-cols-2 gap-x-8 gap-y-2">
{passwordComplexitySettings.minLength != undefined ? (
<div className="flex flex-row items-center" data-testid="length-check">
{hasMinLength ? check : cross}
{renderIcon(hasMinLength, t)}
<span className={desc}>
Password length {passwordComplexitySettings.minLength.toString()}
<Translated
i18nKey="complexity.length"
namespace="password"
data={{ minLength: passwordComplexitySettings.minLength.toString() }}
/>
</span>
</div>
) : (
<span />
)}
<div className="flex flex-row items-center" data-testid="symbol-check">
{hasSymbol ? check : cross}
<span className={desc}>has Symbol</span>
{renderIcon(hasSymbol, t)}
<span className={desc}>
<Translated i18nKey="complexity.hasSymbol" namespace="password" />
</span>
</div>
<div className="flex flex-row items-center" data-testid="number-check">
{hasNumber ? check : cross}
<span className={desc}>has Number</span>
{renderIcon(hasNumber, t)}
<span className={desc}>
<Translated i18nKey="complexity.hasNumber" namespace="password" />
</span>
</div>
<div className="flex flex-row items-center" data-testid="uppercase-check">
{hasUppercase ? check : cross}
<span className={desc}>has uppercase</span>
{renderIcon(hasUppercase, t)}
<span className={desc}>
<Translated i18nKey="complexity.hasUppercase" namespace="password" />
</span>
</div>
<div className="flex flex-row items-center" data-testid="lowercase-check">
{hasLowercase ? check : cross}
<span className={desc}>has lowercase</span>
{renderIcon(hasLowercase, t)}
<span className={desc}>
<Translated i18nKey="complexity.hasLowercase" namespace="password" />
</span>
</div>
<div className="flex flex-row items-center" data-testid="equal-check">
{equals ? check : cross}
<span className={desc}>equals</span>
{renderIcon(equals, t)}
<span className={desc}>
<Translated i18nKey="complexity.equals" namespace="password" />
</span>
</div>
</div>
);