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:
1 parent
1199176883
commit
e004dfedaf
47 files changed
+1740
-471
No files matched your search
+16
-14
@@ -1,3 +1,4 @@
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import Link from "next/link";
|
||||
import { redirect } from "next/navigation";
|
||||
import { ContentCard, EmptyState } from "@/components/public/ui";
|
||||
@@ -16,6 +17,7 @@ function formatTimestamp(seconds: number): string {
|
||||
}
|
||||
|
||||
export default async function MessagesPage() {
|
||||
const t = await getTranslations("pages.messages");
|
||||
const session = await auth();
|
||||
if (!session?.user?.id) redirect("/login");
|
||||
|
||||
@@ -83,23 +85,23 @@ export default async function MessagesPage() {
|
||||
<main style={{ display: "grid", gap: "1.5rem" }}>
|
||||
<ContentCard
|
||||
icon="✉️"
|
||||
title="Messages"
|
||||
subtitle="Friend requests and offline messages waiting for you"
|
||||
title={t("title")}
|
||||
subtitle={t("subtitle")}
|
||||
/>
|
||||
|
||||
{/* ── Pending friend requests ───────────────────────────── */}
|
||||
<ContentCard
|
||||
icon="🙋"
|
||||
title="Friend requests"
|
||||
title={t("requestsTitle")}
|
||||
subtitle={
|
||||
requests.length === 0
|
||||
? "Nobody's asked to be your friend yet"
|
||||
: `${requests.length} pending request${requests.length === 1 ? "" : "s"}`
|
||||
? t("requestsEmptySubtitle")
|
||||
: t("requestsSubtitle", { count: requests.length })
|
||||
}
|
||||
padded={requests.length === 0}
|
||||
>
|
||||
{requests.length === 0 ? (
|
||||
<EmptyState icon="🙋">No pending friend requests.</EmptyState>
|
||||
<EmptyState icon="🙋">{t("requestsEmptyState")}</EmptyState>
|
||||
) : (
|
||||
<div className="grid" style={{ padding: "1rem", gap: "0.75rem" }}>
|
||||
{requests.map((req) => {
|
||||
@@ -129,17 +131,17 @@ export default async function MessagesPage() {
|
||||
<strong>{from.username}</strong>
|
||||
</Link>
|
||||
) : (
|
||||
<strong>User #{req.userFromId}</strong>
|
||||
<strong>{t("unknownUser", { id: req.userFromId })}</strong>
|
||||
)}
|
||||
</p>
|
||||
<p className="muted" style={{ margin: 0 }}>
|
||||
wants to be your friend.
|
||||
{t("wantsToBeFriend")}
|
||||
</p>
|
||||
</div>
|
||||
<form action={acceptFriend}>
|
||||
<input type="hidden" name="requestId" value={String(req.id)} />
|
||||
<button type="submit" className="btn btn-secondary">
|
||||
Accept
|
||||
{t("accept")}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
@@ -152,16 +154,16 @@ export default async function MessagesPage() {
|
||||
{/* ── Offline messages ──────────────────────────────────── */}
|
||||
<ContentCard
|
||||
icon="💬"
|
||||
title="Offline messages"
|
||||
title={t("offlineTitle")}
|
||||
subtitle={
|
||||
messages.length === 0
|
||||
? "Your inbox is empty"
|
||||
: `${messages.length} message${messages.length === 1 ? "" : "s"} received`
|
||||
? t("offlineEmptySubtitle")
|
||||
: t("offlineSubtitle", { count: messages.length })
|
||||
}
|
||||
padded={messages.length === 0}
|
||||
>
|
||||
{messages.length === 0 ? (
|
||||
<EmptyState icon="💬">You have no offline messages.</EmptyState>
|
||||
<EmptyState icon="💬">{t("offlineEmptyState")}</EmptyState>
|
||||
) : (
|
||||
<div className="grid" style={{ padding: "1rem", gap: "0.75rem" }}>
|
||||
{messages.map((msg) => {
|
||||
@@ -193,7 +195,7 @@ export default async function MessagesPage() {
|
||||
{from ? (
|
||||
<Link href={`/u/${from.username}`}>{from.username}</Link>
|
||||
) : (
|
||||
<span>User #{msg.userFromId}</span>
|
||||
<span>{t("unknownUser", { id: msg.userFromId })}</span>
|
||||
)}
|
||||
{when ? <span> · {when}</span> : null}
|
||||
</p>
|
||||
|
||||
Reference in new issue
Block a user