translated

This commit is contained in:
Max Peintner
2025-06-19 14:45:08 +02:00
parent ef8931a17c
commit 68b8019341
7 changed files with 37 additions and 30 deletions

View File

@@ -11,7 +11,7 @@ import {
getLoginSettings, getLoginSettings,
getSession, getSession,
} from "@/lib/zitadel"; } from "@/lib/zitadel";
import { getLocale, getTranslations } from "next-intl/server"; import { getLocale } from "next-intl/server";
import { headers } from "next/headers"; import { headers } from "next/headers";
export default async function Page(props: { export default async function Page(props: {
@@ -21,7 +21,6 @@ export default async function Page(props: {
const params = await props.params; const params = await props.params;
const searchParams = await props.searchParams; const searchParams = await props.searchParams;
const locale = getLocale(); const locale = getLocale();
const t = await getTranslations({ locale, namespace: "otp" });
const _headers = await headers(); const _headers = await headers();
const { serviceUrl } = getServiceUrlFromHeaders(_headers); const { serviceUrl } = getServiceUrlFromHeaders(_headers);
@@ -81,15 +80,23 @@ export default async function Page(props: {
return ( return (
<DynamicTheme branding={branding}> <DynamicTheme branding={branding}>
<div className="flex flex-col items-center space-y-4"> <div className="flex flex-col items-center space-y-4">
<h1>{t("verify.title")}</h1> <h1>
<Translated i18nKey="verify.title" namespace="otp" />
</h1>
{method === "time-based" && ( {method === "time-based" && (
<p className="ztdl-p">{t("verify.totpDescription")}</p> <p className="ztdl-p">
<Translated i18nKey="verify.totpDescription" namespace="otp" />
</p>
)} )}
{method === "sms" && ( {method === "sms" && (
<p className="ztdl-p">{t("verify.smsDescription")}</p> <p className="ztdl-p">
<Translated i18nKey="verify.smsDescription" namespace="otp" />
</p>
)} )}
{method === "email" && ( {method === "email" && (
<p className="ztdl-p">{t("verify.emailDescription")}</p> <p className="ztdl-p">
<Translated i18nKey="verify.emailDescription" namespace="otp" />
</p>
)} )}
{!session && ( {!session && (

View File

@@ -1,7 +1,7 @@
"use client"; "use client";
import { RadioGroup } from "@headlessui/react"; import { RadioGroup } from "@headlessui/react";
import { useTranslations } from "next-intl"; import { Translated } from "./translated";
export enum AuthenticationMethod { export enum AuthenticationMethod {
Passkey = "passkey", Passkey = "passkey",
@@ -20,8 +20,6 @@ export function AuthenticationMethodRadio({
selected: any; selected: any;
selectionChanged: (value: any) => void; selectionChanged: (value: any) => void;
}) { }) {
const t = useTranslations("register");
return ( return (
<div className="w-full"> <div className="w-full">
<div className="mx-auto w-full max-w-md"> <div className="mx-auto w-full max-w-md">
@@ -80,7 +78,18 @@ export function AuthenticationMethodRadio({
as="p" as="p"
className={`font-medium ${checked ? "" : ""}`} className={`font-medium ${checked ? "" : ""}`}
> >
{t(`methods.${method}`)} {method === AuthenticationMethod.Passkey && (
<Translated
i18nKey="methods.passkey"
namespace="register"
/>
)}
{method === AuthenticationMethod.Password && (
<Translated
i18nKey="methods.password"
namespace="register"
/>
)}
</RadioGroup.Label> </RadioGroup.Label>
</div> </div>
</> </>

View File

@@ -1,11 +1,10 @@
"use client"; "use client";
import { useTranslations } from "next-intl";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { Button, ButtonVariants } from "./button"; import { Button, ButtonVariants } from "./button";
import { Translated } from "./translated";
export function BackButton() { export function BackButton() {
const t = useTranslations("common");
const router = useRouter(); const router = useRouter();
return ( return (
<Button <Button
@@ -13,7 +12,7 @@ export function BackButton() {
type="button" type="button"
variant={ButtonVariants.Secondary} variant={ButtonVariants.Secondary}
> >
{t("back")} <Translated i18nKey="back" namespace="common" />
</Button> </Button>
); );
} }

View File

@@ -14,7 +14,6 @@ import {
import { create } from "@zitadel/client"; import { create } from "@zitadel/client";
import { ChecksSchema } from "@zitadel/proto/zitadel/session/v2/session_service_pb"; import { ChecksSchema } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
import { PasswordComplexitySettings } from "@zitadel/proto/zitadel/settings/v2/password_settings_pb"; import { PasswordComplexitySettings } from "@zitadel/proto/zitadel/settings/v2/password_settings_pb";
import { useTranslations } from "next-intl";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { useState } from "react"; import { useState } from "react";
import { FieldValues, useForm } from "react-hook-form"; import { FieldValues, useForm } from "react-hook-form";
@@ -53,8 +52,6 @@ export function SetPasswordForm({
code, code,
codeRequired, codeRequired,
}: Props) { }: Props) {
const t = useTranslations("password");
const { register, handleSubmit, watch, formState } = useForm<Inputs>({ const { register, handleSubmit, watch, formState } = useForm<Inputs>({
mode: "onBlur", mode: "onBlur",
defaultValues: { defaultValues: {
@@ -196,7 +193,7 @@ export function SetPasswordForm({
<Alert type={AlertType.INFO}> <Alert type={AlertType.INFO}>
<div className="flex flex-row"> <div className="flex flex-row">
<span className="flex-1 mr-auto text-left"> <span className="flex-1 mr-auto text-left">
{t("set.noCodeReceived")} <Translated i18nKey="set.noCodeReceived" namespace="password" />
</span> </span>
<button <button
aria-label="Resend OTP Code" aria-label="Resend OTP Code"

View File

@@ -3,7 +3,6 @@
import { getNextUrl } from "@/lib/client"; import { getNextUrl } from "@/lib/client";
import { verifyTOTP } from "@/lib/server/verify"; import { verifyTOTP } from "@/lib/server/verify";
import { LoginSettings } from "@zitadel/proto/zitadel/settings/v2/login_settings_pb"; import { LoginSettings } from "@zitadel/proto/zitadel/settings/v2/login_settings_pb";
import { useTranslations } from "next-intl";
import Link from "next/link"; import Link from "next/link";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { QRCodeSVG } from "qrcode.react"; import { QRCodeSVG } from "qrcode.react";
@@ -14,6 +13,7 @@ import { Button, ButtonVariants } from "./button";
import { CopyToClipboard } from "./copy-to-clipboard"; import { CopyToClipboard } from "./copy-to-clipboard";
import { TextInput } from "./input"; import { TextInput } from "./input";
import { Spinner } from "./spinner"; import { Spinner } from "./spinner";
import { Translated } from "./translated";
type Inputs = { type Inputs = {
code: string; code: string;
@@ -39,8 +39,6 @@ export function TotpRegister({
checkAfter, checkAfter,
loginSettings, loginSettings,
}: Props) { }: Props) {
const t = useTranslations("otp");
const [error, setError] = useState<string>(""); const [error, setError] = useState<string>("");
const [loading, setLoading] = useState<boolean>(false); const [loading, setLoading] = useState<boolean>(false);
const router = useRouter(); const router = useRouter();
@@ -148,7 +146,7 @@ export function TotpRegister({
data-testid="submit-button" data-testid="submit-button"
> >
{loading && <Spinner className="h-5 w-5 mr-2" />} {loading && <Spinner className="h-5 w-5 mr-2" />}
{t("set.submit")} <Translated i18nKey="set.submit" namespace="otp" />
</Button> </Button>
</div> </div>
</form> </form>

View File

@@ -2,7 +2,6 @@
import { sendLoginname } from "@/lib/server/loginname"; import { sendLoginname } from "@/lib/server/loginname";
import { LoginSettings } from "@zitadel/proto/zitadel/settings/v2/login_settings_pb"; import { LoginSettings } from "@zitadel/proto/zitadel/settings/v2/login_settings_pb";
import { useTranslations } from "next-intl";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { ReactNode, useEffect, useState } from "react"; import { ReactNode, useEffect, useState } from "react";
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
@@ -11,6 +10,7 @@ import { BackButton } from "./back-button";
import { Button, ButtonVariants } from "./button"; import { Button, ButtonVariants } from "./button";
import { TextInput } from "./input"; import { TextInput } from "./input";
import { Spinner } from "./spinner"; import { Spinner } from "./spinner";
import { Translated } from "./translated";
type Inputs = { type Inputs = {
loginName: string; loginName: string;
@@ -37,7 +37,6 @@ export function UsernameForm({
allowRegister, allowRegister,
children, children,
}: Props) { }: Props) {
const t = useTranslations("loginname");
const { register, handleSubmit, formState } = useForm<Inputs>({ const { register, handleSubmit, formState } = useForm<Inputs>({
mode: "onBlur", mode: "onBlur",
defaultValues: { defaultValues: {
@@ -127,7 +126,7 @@ export function UsernameForm({
disabled={loading} disabled={loading}
data-testid="register-button" data-testid="register-button"
> >
{t("register")} <Translated i18nKey="register" namespace="loginname" />
</button> </button>
)} )}
</div> </div>

View File

@@ -2,7 +2,6 @@
import { Alert, AlertType } from "@/components/alert"; import { Alert, AlertType } from "@/components/alert";
import { resendVerification, sendVerification } from "@/lib/server/verify"; import { resendVerification, sendVerification } from "@/lib/server/verify";
import { useTranslations } from "next-intl";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { useCallback, useEffect, useState } from "react"; import { useCallback, useEffect, useState } from "react";
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
@@ -10,6 +9,7 @@ import { BackButton } from "./back-button";
import { Button, ButtonVariants } from "./button"; import { Button, ButtonVariants } from "./button";
import { TextInput } from "./input"; import { TextInput } from "./input";
import { Spinner } from "./spinner"; import { Spinner } from "./spinner";
import { Translated } from "./translated";
type Inputs = { type Inputs = {
code: string; code: string;
@@ -32,8 +32,6 @@ export function VerifyForm({
code, code,
isInvite, isInvite,
}: Props) { }: Props) {
const t = useTranslations("verify");
const router = useRouter(); const router = useRouter();
const { register, handleSubmit, formState } = useForm<Inputs>({ const { register, handleSubmit, formState } = useForm<Inputs>({
@@ -117,7 +115,7 @@ export function VerifyForm({
<Alert type={AlertType.INFO}> <Alert type={AlertType.INFO}>
<div className="flex flex-row"> <div className="flex flex-row">
<span className="flex-1 mr-auto text-left"> <span className="flex-1 mr-auto text-left">
{t("verify.noCodeReceived")} <Translated i18nKey="verify.noCodeReceived" namespace="verify" />
</span> </span>
<button <button
aria-label="Resend Code" aria-label="Resend Code"
@@ -129,7 +127,7 @@ export function VerifyForm({
}} }}
data-testid="resend-button" data-testid="resend-button"
> >
{t("verify.resendCode")} <Translated i18nKey="verify.resendCode" namespace="verify" />
</button> </button>
</div> </div>
</Alert> </Alert>
@@ -161,7 +159,7 @@ export function VerifyForm({
data-testid="submit-button" data-testid="submit-button"
> >
{loading && <Spinner className="h-5 w-5 mr-2" />} {loading && <Spinner className="h-5 w-5 mr-2" />}
{t("verify.submit")} <Translated i18nKey="verify.submit" namespace="verify" />
</Button> </Button>
</div> </div>
</form> </form>