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

+17 -17
View File
@@ -1,3 +1,4 @@
import { getTranslations } from "next-intl/server";
import { redirect } from "next/navigation";
import { applyStaff } from "@/actions/applications";
import { ContentCard, EmptyState } from "@/components/public/ui";
@@ -10,18 +11,20 @@ export const dynamic = "force-dynamic";
// Canonical Habbo badge image CDN (same base used by the profile page).
const BADGE_IMG_BASE = "https://images.habbo.com/c_images/album1584";
function formatDeadline(d: Date | null | undefined): string {
if (!d) return "No deadline set";
return d.toISOString().slice(0, 16).replace("T", " ");
}
export default async function ApplyStaffPage() {
const session = await auth();
if (!session?.user?.id) redirect("/login");
const t = await getTranslations("pages.applyStaff");
const userId = Number(session.user.id);
const hotelName = (await siteSettings.get("hotel_name", "Atom")) ?? "Atom";
function formatDeadline(d: Date | null | undefined): string {
if (!d) return t("noDeadline");
return d.toISOString().slice(0, 16).replace("T", " ");
}
// ── Open positions ──────────────────────────────────────────
// Each query is isolated so a DB hiccup degrades that section to empty
// rather than 500-ing the whole page.
@@ -52,16 +55,13 @@ export default async function ApplyStaffPage() {
<main style={{ display: "grid", gap: "1.5rem" }}>
<ContentCard
icon="🛡️"
title={`Apply for ${hotelName} staff`}
subtitle="We open staff applications every now and then. If you come across a position you feel you would fit perfectly into, do not hesitate to apply for it."
title={t("title", { hotel: hotelName })}
subtitle={t("subtitle")}
/>
{positions.length === 0 ? (
<ContentCard icon="🛡️" title="No positions open">
<EmptyState icon="🛡️">
There are currently no positions open. Please come back at a later time to check if we
have any openings by then. Thank you for your interest.
</EmptyState>
<ContentCard icon="🛡️" title={t("noPositionsTitle")}>
<EmptyState icon="🛡️">{t("noPositionsBody")}</EmptyState>
</ContentCard>
) : (
<div className="card-grid sm-2">
@@ -98,7 +98,7 @@ export default async function ApplyStaffPage() {
<div className="content-card-body">
<p style={{ margin: "0 0 0.5rem" }}>{position.description}</p>
<p className="muted" style={{ margin: "0 0 0.75rem" }}>
Application deadline: {formatDeadline(position.applyTo)}
{t("deadline", { date: formatDeadline(position.applyTo) })}
</p>
{alreadyApplied ? (
@@ -108,7 +108,7 @@ export default async function ApplyStaffPage() {
disabled
style={{ width: "100%" }}
>
You have already applied for {rankName}
{t("alreadyApplied", { rank: rankName })}
</button>
) : (
<form action={applyStaff}>
@@ -116,7 +116,7 @@ export default async function ApplyStaffPage() {
re-read from the session inside the action. */}
<input type="hidden" name="rankId" value={String(position.permissionId)} />
<label htmlFor={`content-${position.id}`} className="muted">
About you
{t("aboutYou")}
</label>
<textarea
id={`content-${position.id}`}
@@ -124,11 +124,11 @@ export default async function ApplyStaffPage() {
required
minLength={10}
rows={5}
placeholder={`Tell us why you'd be a great ${rankName}…`}
placeholder={t("aboutPlaceholder", { rank: rankName })}
style={{ width: "100%", margin: "0.4rem 0 0.75rem", resize: "vertical" }}
/>
<button type="submit" className="btn btn-secondary" style={{ width: "100%" }}>
Apply for {rankName}
{t("applyFor", { rank: rankName })}
</button>
</form>
)}
+11 -11
View File
@@ -1,3 +1,4 @@
import { getTranslations } from "next-intl/server";
import { redirect } from "next/navigation";
import { applyTeam } from "@/actions/applications";
import { ContentCard, EmptyState } from "@/components/public/ui";
@@ -14,6 +15,8 @@ export default async function ApplyTeamPage() {
const session = await auth();
if (!session?.user?.id) redirect("/login");
const t = await getTranslations("pages.applyTeam");
const userId = Number(session.user.id);
const hotelName = (await siteSettings.get("hotel_name", "Atom")) ?? "Atom";
@@ -39,16 +42,13 @@ export default async function ApplyTeamPage() {
<main style={{ display: "grid", gap: "1.5rem" }}>
<ContentCard
icon="🤝"
title={`Apply for the ${hotelName} team`}
subtitle="We open team applications periodically. If you see a team you fit, do not hesitate to apply!"
title={t("title", { hotel: hotelName })}
subtitle={t("subtitle")}
/>
{teams.length === 0 ? (
<ContentCard icon="🤝" title="No team positions open">
<EmptyState icon="🤝">
There are currently no open team positions. Please come back later to check for new
openings. Thank you!
</EmptyState>
<ContentCard icon="🤝" title={t("noPositionsTitle")}>
<EmptyState icon="🤝">{t("noPositionsBody")}</EmptyState>
</ContentCard>
) : (
<div className="card-grid sm-2">
@@ -89,7 +89,7 @@ export default async function ApplyTeamPage() {
disabled
style={{ width: "100%" }}
>
Your application is pending
{t("pending")}
</button>
) : (
<form action={applyTeam}>
@@ -97,7 +97,7 @@ export default async function ApplyTeamPage() {
is re-read from the session inside the action. */}
<input type="hidden" name="teamId" value={String(team.id)} />
<label htmlFor={`content-${team.id}`} className="muted">
About you
{t("aboutYou")}
</label>
<textarea
id={`content-${team.id}`}
@@ -105,11 +105,11 @@ export default async function ApplyTeamPage() {
required
minLength={10}
rows={5}
placeholder={`Tell us why you'd be a great fit for ${team.rankName}…`}
placeholder={t("aboutPlaceholder", { rank: team.rankName })}
style={{ width: "100%", margin: "0.4rem 0 0.75rem", resize: "vertical" }}
/>
<button type="submit" className="btn btn-primary" style={{ width: "100%" }}>
Apply for {team.rankName}
{t("applyFor", { rank: team.rankName })}
</button>
</form>
)}