i18n: translate all public page bodies (EN + IT)

Internationalised the ~44 public pages with next-intl (the shell was
already translated). Each page now pulls its copy from a "pages.<slug>"
namespace via getTranslations (server) / useTranslations (client); the
EN + IT catalogs were authored by parallel agents and merged centrally,
with natural Italian (ICU plurals) and it backfilled from en for any
gap. request.ts gained getMessageFallback/onError so a missing key
degrades to the English value, never a raw key.

Behaviour unchanged (only display text moved to t() calls; queries,
actions, fields, ContentCard structure preserved). Verified on the prod
server: with NEXT_LOCALE=it, home/community/staff/news/shop/rankings all
render Italian copy, no raw-key leakage; English unchanged. The nav
language switcher toggles EN/IT live. tsc 0, vitest 49/49, next build 0.

Admin pages intentionally left in English (staff tooling).
This commit is contained in:
Simo committed 2026-06-28 20:40:06 +02:00
1 parent 1199176883
commit e004dfedaf
47 files changed
+1740 -471

No files matched your search

+19 -17
View File
@@ -1,4 +1,5 @@
import Link from "next/link";
import { getTranslations } from "next-intl/server";
import { redirect } from "next/navigation";
import { beginTwoFactor, confirmTwoFactor, disableTwoFactor } from "@/actions/twofactor";
import { ContentCard } from "@/components/public/ui";
@@ -16,6 +17,7 @@ export default async function TwoFactorPage({
}: {
searchParams: Promise<{ error?: string; enabled?: string; disabled?: string }>;
}) {
const t = await getTranslations("pages.settings2fa");
const session = await auth();
if (!session?.user?.id) redirect("/login");
const sp = await searchParams;
@@ -50,52 +52,52 @@ export default async function TwoFactorPage({
return (
<main style={{ display: "grid", gap: "1.5rem", maxWidth: 560, margin: "0 auto" }}>
<p className="muted" style={{ margin: 0 }}>
<Link href="/settings">← Settings</Link>
<Link href="/settings">{t("backToSettings")}</Link>
</p>
<ContentCard
icon="🔒"
title="Two-factor authentication"
subtitle="Add a second layer of security with an authenticator app"
title={t("title")}
subtitle={t("subtitle")}
>
{sp.enabled ? (
<p style={{ color: "var(--color-accent)", marginTop: 0 }}>2FA is now enabled. 🔒</p>
<p style={{ color: "var(--color-accent)", marginTop: 0 }}>{t("nowEnabled")}</p>
) : null}
{sp.disabled ? (
<p className="muted" style={{ marginTop: 0 }}>
2FA has been disabled.
{t("disabledNotice")}
</p>
) : null}
{sp.error === "badcode" ? (
<p style={{ color: "var(--color-danger)", marginTop: 0 }}>
That code wasn't valid — try again.
{t("badCode")}
</p>
) : null}
{!hasAppKey ? (
<p style={{ margin: 0 }}>
2FA is unavailable until <code>APP_KEY</code> is configured (the same Laravel
<code> APP_KEY</code> as your AtomCMS install, so existing secrets stay readable).
{t("noAppKeyPrefix")} <code>APP_KEY</code> {t("noAppKeyMiddle")}
<code> APP_KEY</code> {t("noAppKeySuffix")}
</p>
) : enabled ? (
<>
<p style={{ marginTop: 0 }}>
<strong>2FA is enabled</strong> on your account.
<strong>{t("isEnabled")}</strong> {t("onYourAccount")}
</p>
<form action={disableTwoFactor}>
<button type="submit" className="btn btn-danger">
Disable 2FA
{t("disable")}
</button>
</form>
</>
) : pending ? (
<>
<h3 style={{ marginTop: 0 }}>Scan or enter this key</h3>
<h3 style={{ marginTop: 0 }}>{t("scanOrEnter")}</h3>
<p className="muted" style={{ marginTop: 0 }}>
Add this to Google Authenticator / Authy, then enter the 6-digit code to confirm.
{t("scanInstructions")}
</p>
<p>
Manual key: <code style={{ userSelect: "all" }}>{secret}</code>
{t("manualKey")} <code style={{ userSelect: "all" }}>{secret}</code>
</p>
<p className="muted" style={{ wordBreak: "break-all", fontSize: "0.8rem" }}>
{uri}
@@ -104,20 +106,20 @@ export default async function TwoFactorPage({
action={confirmTwoFactor}
style={{ display: "flex", gap: "0.5rem", marginTop: "0.5rem" }}
>
<input name="code" placeholder="6-digit code" inputMode="numeric" required />
<input name="code" placeholder={t("codePlaceholder")} inputMode="numeric" required />
<button type="submit" className="btn btn-primary">
Confirm
{t("confirm")}
</button>
</form>
</>
) : (
<>
<p style={{ marginTop: 0 }}>
Add a second layer of security with an authenticator app.
{t("enableIntro")}
</p>
<form action={beginTwoFactor}>
<button type="submit" className="btn btn-primary">
Enable 2FA
{t("enable")}
</button>
</form>
</>
+14 -14
View File
@@ -1,4 +1,5 @@
import Link from "next/link";
import { getTranslations } from "next-intl/server";
import { redirect } from "next/navigation";
import { ContentCard } from "@/components/public/ui";
import { auth } from "@/lib/auth";
@@ -27,6 +28,7 @@ const PROVIDERS = [
] as const;
export default async function ConnectionsPage() {
const t = await getTranslations("pages.connections");
const session = await auth();
if (!session?.user?.id) redirect("/login");
@@ -53,23 +55,22 @@ export default async function ConnectionsPage() {
return (
<main style={{ display: "grid", gap: "1.5rem", maxWidth: 620, margin: "0 auto" }}>
<p className="muted" style={{ margin: 0 }}>
<Link href="/settings">← Settings</Link>
<Link href="/settings">{t("backToSettings")}</Link>
</p>
<ContentCard
icon="🔗"
title="Connected accounts"
subtitle="Link a social account so you can sign in with one click"
title={t("title")}
subtitle={t("subtitle")}
>
<p className="muted" style={{ marginTop: 0 }}>
We match it to your hotel account by e-mail, so use the address on file:{" "}
{t("matchByEmail")}{" "}
<strong>{session.user.name}</strong>.
</p>
{lookupFailed ? (
<p className="muted" style={{ marginBottom: 0 }}>
We couldn't read your linked accounts right now. You can still connect below — your
status will show once it's available.
{t("lookupFailed")}
</p>
) : null}
</ContentCard>
@@ -84,10 +85,10 @@ export default async function ConnectionsPage() {
title={p.label}
subtitle={
!p.available
? "Not available on this hotel."
? t("statusUnavailable")
: isLinked
? "Connected — sign in with this account."
: "Not connected."
? t("statusConnected")
: t("statusNotConnected")
}
>
{isLinked ? (
@@ -96,7 +97,7 @@ export default async function ConnectionsPage() {
style={{ cursor: "default", pointerEvents: "none" }}
aria-disabled="true"
>
Connected
{t("connected")}
</span>
) : p.available ? (
// Plain link into NextAuth's built-in sign-in handler. Re-using
@@ -108,7 +109,7 @@ export default async function ConnectionsPage() {
callbackUrl,
)}`}
>
Connect {p.label}
{t("connectProvider", { provider: p.label })}
</a>
) : (
<span
@@ -116,7 +117,7 @@ export default async function ConnectionsPage() {
style={{ cursor: "not-allowed", opacity: 0.55, pointerEvents: "none" }}
aria-disabled="true"
>
Unavailable
{t("unavailable")}
</span>
)}
</ContentCard>
@@ -125,8 +126,7 @@ export default async function ConnectionsPage() {
</div>
<p className="muted" style={{ margin: 0 }}>
Connecting takes you to the provider to authorise, then back here. If your social account's
e-mail doesn't match a hotel account, you'll be returned to the login screen with a note.
{t("footerNote")}
</p>
</main>
);
+16 -14
View File
@@ -1,4 +1,5 @@
import Link from "next/link";
import { getTranslations } from "next-intl/server";
import { redirect } from "next/navigation";
import { updateMotto } from "@/actions/user-settings";
import { ContentCard } from "@/components/public/ui";
@@ -10,6 +11,7 @@ import { siteSettings } from "@/lib/services/site-settings";
export const dynamic = "force-dynamic";
export default async function SettingsPage() {
const t = await getTranslations("pages.settings");
const session = await auth();
if (!session?.user?.id) redirect("/login");
@@ -46,11 +48,11 @@ export default async function SettingsPage() {
<main style={{ display: "grid", gap: "1.5rem" }}>
<ContentCard
icon="⚙️"
title="Account settings"
subtitle="Manage your profile, security and connected accounts"
title={t("accountSettings")}
subtitle={t("accountSettingsSubtitle")}
/>
<ContentCard icon="🙂" title={user.username} subtitle="Your public profile">
<ContentCard icon="🙂" title={user.username} subtitle={t("publicProfile")}>
<div style={{ display: "flex", gap: "1.5rem", alignItems: "center", flexWrap: "wrap" }}>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
@@ -62,16 +64,16 @@ export default async function SettingsPage() {
/>
<div style={{ minWidth: 0 }}>
<p style={{ margin: "0 0 0.5rem", fontSize: "1.05rem" }}>
{user.motto || <span className="muted">No motto</span>}
{user.motto || <span className="muted">{t("noMotto")}</span>}
</p>
<p className="muted" style={{ margin: 0 }}>
{user.mail || "No e-mail on file"}
{user.mail || t("noEmail")}
</p>
</div>
</div>
</ContentCard>
<ContentCard icon="✏️" title="Change motto" subtitle="Updates instantly in-game if you are online">
<ContentCard icon="✏️" title={t("changeMotto")} subtitle={t("changeMottoSubtitle")}>
<form
action={updateMotto}
style={{ display: "flex", flexDirection: "column", gap: "0.75rem", maxWidth: 520 }}
@@ -80,33 +82,33 @@ export default async function SettingsPage() {
name="motto"
defaultValue={user.motto}
maxLength={127}
placeholder="Your motto"
placeholder={t("mottoPlaceholder")}
aria-label="Motto"
/>
<div>
<button type="submit" className="btn btn-primary">
Save motto
{t("saveMotto")}
</button>
</div>
</form>
</ContentCard>
<div className="card-grid sm-2">
<ContentCard icon="🔒" title="Security" subtitle="Two-factor authentication">
<ContentCard icon="🔒" title={t("securityTitle")} subtitle={t("securitySubtitle")}>
<p className="muted" style={{ marginTop: 0 }}>
Add a second layer of protection to your account.
{t("securityDescription")}
</p>
<Link href="/settings/2fa" className="btn btn-outline">
Two-factor authentication
{t("twoFactorLink")}
</Link>
</ContentCard>
<ContentCard icon="🔗" title="Connected accounts" subtitle="Sign in with one click">
<ContentCard icon="🔗" title={t("connectionsTitle")} subtitle={t("connectionsSubtitle")}>
<p className="muted" style={{ marginTop: 0 }}>
Link Discord or Google to your hotel account.
{t("connectionsDescription")}
</p>
<Link href="/settings/connections" className="btn btn-outline">
Manage connections
{t("manageConnections")}
</Link>
</ContentCard>
</div>