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

+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>