Translate admin panel to all 6 languages

This commit is contained in:
openhands committed 2026-07-04 21:21:15 +02:00
1 parent f381aa987f
commit befa4ec282
63 files changed
+9353 -1443

No files matched your search

+23 -21
View File
@@ -1,4 +1,5 @@
import Link from "next/link";
import { getTranslations } from "next-intl/server";
import { notFound } from "next/navigation";
import { prisma } from "@/lib/prisma";
import { DoorOpen } from "lucide-react";
@@ -10,8 +11,9 @@ export default async function AdminRoomDetail({
}: {
params: Promise<{ id: string }>;
}) {
const t = await getTranslations("pages.admin.rooms");
const { id } = await params;
// rooms is an emulator-owned table → Int id.
const roomId = Number(id);
if (!Number.isInteger(roomId) || roomId <= 0) notFound();
@@ -25,36 +27,36 @@ export default async function AdminRoomDetail({
if (!room) notFound();
const fields: Array<[string, string]> = [
["ID", String(room.id)],
["Name", room.name || "(unnamed)"],
["Description", room.description || "—"],
["Owner", `${room.ownerName || "—"} (#${room.ownerId})`],
["State", room.state],
["Users", `${room.users} / ${room.usersMax}`],
["Category", String(room.category)],
["Score", String(room.score)],
["Model", room.model],
["Guild ID", room.guildId ? String(room.guildId) : "—"],
["Tags", room.tags || "—"],
["Password", room.password ? "yes" : "—"],
["Public", room.isPublic === "1" ? "yes" : "no"],
["Staff picked", room.isStaffPicked === "1" ? "yes" : "no"],
["For sale", room.isForSale === "1" ? "yes" : "no"],
["Trade mode", String(room.tradeMode)],
[t("colId"), String(room.id)],
[t("colName"), room.name || t("unnamed")],
[t("detail.description"), room.description || "—"],
[t("detail.owner"), `${room.ownerName || "—"} (#${room.ownerId})`],
[t("detail.state"), room.state],
[t("colUsers"), `${room.users} / ${room.usersMax}`],
[t("colCategory"), String(room.category)],
[t("detail.score"), String(room.score)],
[t("detail.model"), room.model],
[t("detail.guildId"), room.guildId ? String(room.guildId) : "—"],
[t("detail.tags"), room.tags || "—"],
[t("detail.password"), room.password ? t("detail.yes") : "—"],
[t("detail.public"), room.isPublic === "1" ? t("detail.yes") : t("detail.no")],
[t("detail.staffPicked"), room.isStaffPicked === "1" ? t("detail.yes") : t("detail.no")],
[t("detail.forSale"), room.isForSale === "1" ? t("detail.yes") : t("detail.no")],
[t("detail.tradeMode"), String(room.tradeMode)],
];
return (
<main>
<p className="text-sm text-gray-500 dark:text-gray-400 mb-1">
<Link href="/admin/rooms">← Rooms</Link>
<Link href="/admin/rooms">← {t("title")}</Link>
</p>
<div className="flex items-center gap-3 mb-6">
<div className="w-10 h-10 rounded-xl bg-gradient-to-br from-[var(--color-primary)]/20 to-[var(--color-primary)]/5 grid place-items-center">
<DoorOpen size={20} className="text-[var(--color-primary)]" />
</div>
<div>
<h1 className="m-0 text-xl font-extrabold text-[var(--color-text)]">{room.name || "(unnamed)"}</h1>
<p className="m-0 text-xs text-[var(--color-text-muted)] mt-0.5">ID {room.id} · owner {room.ownerName || "—"} · {room.users}/{room.usersMax} users · {room.state}</p>
<h1 className="m-0 text-xl font-extrabold text-[var(--color-text)]">{room.name || t("unnamed")}</h1>
<p className="m-0 text-xs text-[var(--color-text-muted)] mt-0.5">{t("detail.subtitle", { id: room.id, owner: room.ownerName || "—", users: room.users, maxUsers: room.usersMax, state: room.state })}</p>
</div>
</div>
@@ -73,7 +75,7 @@ export default async function AdminRoomDetail({
{room.ownerId ? (
<p className="muted" style={{ marginTop: "1rem" }}>
<Link href={`/admin/users/${room.ownerId}`}>View owner →</Link>
<Link href={`/admin/users/${room.ownerId}`}>{t("detail.viewOwner")} →</Link>
</p>
) : null}
</main>
+21 -21
View File
@@ -1,4 +1,5 @@
import Link from "next/link";
import { getTranslations } from "next-intl/server";
import { StatusCard } from "@/components/admin/dashboard";
import { prisma } from "@/lib/prisma";
import { DoorOpen } from "lucide-react";
@@ -22,12 +23,12 @@ export default async function AdminRooms({
}: {
searchParams: Promise<{ q?: string; page?: string }>;
}) {
const t = await getTranslations("pages.admin.rooms");
const sp = await searchParams;
const q = (sp.q ?? "").trim();
const page = Math.max(1, Number(sp.page ?? "1") || 1);
// Search matches room name OR owner username (ownerName is denormalised on the
// emulator rooms table, so no join is needed).
const where = q
? { OR: [{ name: { contains: q } }, { ownerName: { contains: q } }] }
: {};
@@ -62,7 +63,6 @@ export default async function AdminRooms({
const qs = (p: number) =>
`/admin/rooms?q=${encodeURIComponent(q)}&page=${p}`;
// Page-local tallies (the full counts aren't fetched to keep the query cheap).
const openOnPage = rooms.filter((r) => r.state === "open").length;
const usersOnPage = rooms.reduce((sum, r) => sum + r.users, 0);
@@ -73,21 +73,21 @@ export default async function AdminRooms({
<DoorOpen size={20} className="text-[var(--color-primary)]" />
</div>
<div>
<h1 className="m-0 text-xl font-extrabold text-[var(--color-text)]">Rooms</h1>
<p className="m-0 text-xs text-[var(--color-text-muted)] mt-0.5">{q ? `Matching "${q}" · ` : ""}{total} room{total === 1 ? "" : "s"} total.</p>
<h1 className="m-0 text-xl font-extrabold text-[var(--color-text)]">{t("title")}</h1>
<p className="m-0 text-xs text-[var(--color-text-muted)] mt-0.5">{q ? t("matchingQuery", { query: q }) + " · " : ""}{t("totalRooms", { count: total })}</p>
</div>
</div>
<div className="grid grid-cols-[repeat(auto-fit,minmax(180px,1fr))] gap-3.5 mb-6">
<StatusCard label={q ? "Matching rooms" : "Total rooms"} value={total} icon="🏠" />
<StatusCard label="Open (this page)" value={openOnPage} state="ok" icon="🔓" />
<StatusCard label="Users in-room (this page)" value={usersOnPage} icon="👥" />
<StatusCard label={q ? t("matchingRooms") : t("totalRooms", { count: total })} value={total} icon="🏠" />
<StatusCard label={t("openThisPage")} value={openOnPage} state="ok" icon="🔓" />
<StatusCard label={t("usersInRoom")} value={usersOnPage} icon="👥" />
</div>
<form className="flex gap-2 mb-4">
<input name="q" defaultValue={q} placeholder="Search room or owner" />
<input name="q" defaultValue={q} placeholder={t("searchPlaceholder")} />
<button type="submit" className="btn btn-primary">
Search
{t("search")}
</button>
</form>
@@ -95,12 +95,12 @@ export default async function AdminRooms({
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Owner</th>
<th>Users</th>
<th>State</th>
<th>Cat</th>
<th>{t("colId")}</th>
<th>{t("colName")}</th>
<th>{t("colOwner")}</th>
<th>{t("colUsers")}</th>
<th>{t("colState")}</th>
<th>{t("colCategory")}</th>
</tr>
</thead>
<tbody>
@@ -108,7 +108,7 @@ export default async function AdminRooms({
<tr key={r.id}>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">{r.id}</td>
<td>
<Link href={`/admin/rooms/${r.id}`}>{r.name || "(unnamed)"}</Link>
<Link href={`/admin/rooms/${r.id}`}>{r.name || t("unnamed")}</Link>
</td>
<td>{r.ownerName || "—"}</td>
<td>
@@ -128,22 +128,22 @@ export default async function AdminRooms({
{rooms.length === 0 ? (
<p className="text-xs text-gray-500 dark:text-gray-400" style={{ marginTop: "1rem" }}>
No rooms found.
{t("noRooms")}
</p>
) : null}
<p className="text-xs text-gray-500 dark:text-gray-400" style={{ marginTop: "1rem" }}>
Page {page} / {pages} · {total} rooms
{t("pagination", { page, pages, total })}
{page > 1 ? (
<>
{" · "}
<Link href={qs(page - 1)}>← Prev</Link>
<Link href={qs(page - 1)}>← {t("prev")}</Link>
</>
) : null}
{page < pages ? (
<>
{" · "}
<Link href={qs(page + 1)}>Next →</Link>
<Link href={qs(page + 1)}>{t("next")} →</Link>
</>
) : null}
</p>