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

+85 -76
View File
@@ -1,5 +1,6 @@
import { redirect } from "next/navigation";
import type { ReactNode } from "react";
import { getTranslations } from "next-intl/server";
import { AdminNavLink } from "@/components/admin/admin-nav-link";
import { requireStaff } from "@/lib/admin/guard";
import { prisma } from "@/lib/prisma";
@@ -15,77 +16,81 @@ import {
export const dynamic = "force-dynamic";
const NAV_GROUPS: { label: string; icon: ReactNode; items: { href: string; label: string; icon: ReactNode }[] }[] = [
{
label: "Overview", icon: <LayoutDashboard size={14} />,
items: [{ href: "/admin", label: "Dashboard", icon: <LayoutDashboard size={16} /> }],
},
{
label: "Content", icon: <Newspaper size={14} />,
items: [
{ href: "/admin/articles", label: "Articles", icon: <Newspaper size={16} /> },
{ href: "/admin/tags", label: "Tags", icon: <Tags size={16} /> },
{ href: "/admin/navigation", label: "Navigator", icon: <Compass size={16} /> },
{ href: "/admin/help-questions", label: "Help center", icon: <HelpCircle size={16} /> },
{ href: "/admin/ads", label: "Advertisements", icon: <Megaphone size={16} /> },
{ href: "/admin/writeable-boxes", label: "Writeable boxes", icon: <SquarePen size={16} /> },
{ href: "/admin/photos", label: "Photos", icon: <Image size={16} /> },
],
},
{
label: "Users & access", icon: <Shield size={14} />,
items: [
{ href: "/admin/users", label: "Users", icon: <Users size={16} /> },
{ href: "/admin/bans", label: "Bans", icon: <Ban size={16} /> },
{ href: "/admin/ip", label: "IP management", icon: <Globe size={16} /> },
{ href: "/admin/vpn", label: "VPN", icon: <Shield size={16} /> },
{ href: "/admin/applications", label: "Applications", icon: <ClipboardList size={16} /> },
{ href: "/admin/teams", label: "Teams", icon: <Group size={16} /> },
{ href: "/admin/permissions", label: "Permissions", icon: <Key size={16} /> },
],
},
{
label: "Economy", icon: <ShoppingCart size={14} />,
items: [
{ href: "/admin/catalog", label: "Catalog", icon: <Store size={16} /> },
{ href: "/admin/shop", label: "Shop", icon: <ShoppingCart size={16} /> },
{ href: "/admin/transactions", label: "Transactions", icon: <Receipt size={16} /> },
{ href: "/admin/vouchers", label: "Vouchers", icon: <Ticket size={16} /> },
{ href: "/admin/subscriptions", label: "Subscriptions", icon: <CreditCard size={16} /> },
{ href: "/admin/rare-values", label: "Rare values", icon: <Gem size={16} /> },
{ href: "/admin/badges", label: "Badges", icon: <Award size={16} /> },
{ href: "/admin/achievements", label: "Achievements", icon: <Trophy size={16} /> },
{ href: "/admin/calendar", label: "Calendar", icon: <Calendar size={16} /> },
],
},
{
label: "Radio", icon: <Radio size={14} />,
items: [
{ href: "/admin/radio", label: "Radio", icon: <Radio size={16} /> },
{ href: "/admin/radio/history", label: "Radio history", icon: <History size={16} /> },
],
},
{
label: "System", icon: <Settings size={14} />,
items: [
{ href: "/admin/commandocentrum", label: "Commandocentrum", icon: <Terminal size={16} /> },
{ href: "/admin/emulator", label: "Emulator", icon: <Monitor size={16} /> },
{ href: "/admin/alerts", label: "Alerts", icon: <Bell size={16} /> },
{ href: "/admin/logs", label: "Logs", icon: <FileText size={16} /> },
{ href: "/admin/wordfilter", label: "Word filter", icon: <Filter size={16} /> },
{ href: "/admin/maintenance", label: "Maintenance", icon: <Wrench size={16} /> },
{ href: "/admin/housekeeping", label: "Housekeeping", icon: <Settings size={16} /> },
{ href: "/admin/rooms", label: "Rooms", icon: <DoorOpen size={16} /> },
{ href: "/admin/email-templates", label: "Email templates", icon: <Mail size={16} /> },
{ href: "/admin/theme", label: "Theme", icon: <Palette size={16} /> },
{ href: "/admin/media", label: "Media", icon: <Image size={16} /> },
{ href: "/admin/settings", label: "Settings", icon: <Cog size={16} /> },
],
},
];
function getNavGroups(t: (key: string) => string) {
return [
{
label: t("overview"), icon: <LayoutDashboard size={14} />,
items: [{ href: "/admin", label: t("dashboard"), icon: <LayoutDashboard size={16} /> }],
},
{
label: t("content"), icon: <Newspaper size={14} />,
items: [
{ href: "/admin/articles", label: t("articles"), icon: <Newspaper size={16} /> },
{ href: "/admin/tags", label: t("tags"), icon: <Tags size={16} /> },
{ href: "/admin/navigation", label: t("navigator"), icon: <Compass size={16} /> },
{ href: "/admin/help-questions", label: t("helpCenter"), icon: <HelpCircle size={16} /> },
{ href: "/admin/ads", label: t("advertisements"), icon: <Megaphone size={16} /> },
{ href: "/admin/writeable-boxes", label: t("writeableBoxes"), icon: <SquarePen size={16} /> },
{ href: "/admin/photos", label: t("photos"), icon: <Image size={16} /> },
],
},
{
label: t("usersAccess"), icon: <Shield size={14} />,
items: [
{ href: "/admin/users", label: t("users"), icon: <Users size={16} /> },
{ href: "/admin/bans", label: t("bans"), icon: <Ban size={16} /> },
{ href: "/admin/ip", label: t("ipManagement"), icon: <Globe size={16} /> },
{ href: "/admin/vpn", label: t("vpn"), icon: <Shield size={16} /> },
{ href: "/admin/applications", label: t("applications"), icon: <ClipboardList size={16} /> },
{ href: "/admin/teams", label: t("teams"), icon: <Group size={16} /> },
{ href: "/admin/permissions", label: t("permissions"), icon: <Key size={16} /> },
],
},
{
label: t("economy"), icon: <ShoppingCart size={14} />,
items: [
{ href: "/admin/catalog", label: t("catalog"), icon: <Store size={16} /> },
{ href: "/admin/shop", label: t("shop"), icon: <ShoppingCart size={16} /> },
{ href: "/admin/transactions", label: t("transactions"), icon: <Receipt size={16} /> },
{ href: "/admin/vouchers", label: t("vouchers"), icon: <Ticket size={16} /> },
{ href: "/admin/subscriptions", label: t("subscriptions"), icon: <CreditCard size={16} /> },
{ href: "/admin/rare-values", label: t("rareValues"), icon: <Gem size={16} /> },
{ href: "/admin/badges", label: t("badges"), icon: <Award size={16} /> },
{ href: "/admin/achievements", label: t("achievements"), icon: <Trophy size={16} /> },
{ href: "/admin/calendar", label: t("calendar"), icon: <Calendar size={16} /> },
],
},
{
label: t("radio"), icon: <Radio size={14} />,
items: [
{ href: "/admin/radio", label: t("radio"), icon: <Radio size={16} /> },
{ href: "/admin/radio/history", label: t("radioHistory"), icon: <History size={16} /> },
],
},
{
label: t("system"), icon: <Settings size={14} />,
items: [
{ href: "/admin/commandocentrum", label: t("commandocentrum"), icon: <Terminal size={16} /> },
{ href: "/admin/emulator", label: t("emulator"), icon: <Monitor size={16} /> },
{ href: "/admin/alerts", label: t("alerts"), icon: <Bell size={16} /> },
{ href: "/admin/logs", label: t("logs"), icon: <FileText size={16} /> },
{ href: "/admin/wordfilter", label: t("wordFilter"), icon: <Filter size={16} /> },
{ href: "/admin/maintenance", label: t("maintenance"), icon: <Wrench size={16} /> },
{ href: "/admin/housekeeping", label: t("housekeeping"), icon: <Settings size={16} /> },
{ href: "/admin/rooms", label: t("rooms"), icon: <DoorOpen size={16} /> },
{ href: "/admin/email-templates", label: t("emailTemplates"), icon: <Mail size={16} /> },
{ href: "/admin/theme", label: t("theme"), icon: <Palette size={16} /> },
{ href: "/admin/media", label: t("media"), icon: <Image size={16} /> },
{ href: "/admin/settings", label: t("settings"), icon: <Cog size={16} /> },
],
},
];
}
export default async function AdminLayout({ children }: { children: ReactNode }) {
const staff = await requireStaff();
const t = await getTranslations("pages.admin.nav");
const navGroups = getNavGroups(t);
if (await siteSettings.getBool("force_staff_2fa", false)) {
const u = await prisma.user
@@ -105,8 +110,10 @@ export default async function AdminLayout({ children }: { children: ReactNode })
);
}
function Sidebar({ staff }: { staff: { id: number; username: string; rank: number } }) {
async function Sidebar({ staff }: { staff: { id: number; username: string; rank: number } }) {
const t = await getTranslations("pages.admin.nav");
const initial = staff.username.charAt(0).toUpperCase();
const navGroups = getNavGroups(t);
return (
<aside className="sticky top-0 self-start h-screen bg-gradient-to-b from-[#1e1b2e] to-[#151226] text-[#c8cbe0] shadow-xl flex flex-col">
@@ -116,12 +123,12 @@ function Sidebar({ staff }: { staff: { id: number; username: string; rank: numbe
</span>
<div className="min-w-0 flex-1">
<div className="font-semibold text-sm text-white truncate">{staff.username}</div>
<span className="inline-block mt-0.5 text-[0.6rem] font-bold uppercase tracking-widest text-[rgba(200,203,224,0.5)]">rank {staff.rank}</span>
<span className="inline-block mt-0.5 text-[0.6rem] font-bold uppercase tracking-widest text-[rgba(200,203,224,0.5)]">{t("rankLabel", { rank: staff.rank })}</span>
</div>
</div>
<nav className="flex-1 overflow-y-auto px-3 py-4 space-y-1">
{NAV_GROUPS.map((group) => (
{navGroups.map((group) => (
<div key={group.label}>
<div className="flex items-center gap-1.5 px-2 py-2 text-[0.6rem] font-bold uppercase tracking-[0.12em] text-[rgba(200,203,224,0.3)]">
{group.icon}
@@ -144,21 +151,23 @@ function Sidebar({ staff }: { staff: { id: number; username: string; rank: numbe
className="flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-[#c8cbe0]/60 text-xs font-medium hover:text-white hover:bg-white/5 transition-all duration-150 no-underline"
>
<LogOut size={14} />
<span>Back to site</span>
<span>{t("backToSite")}</span>
</a>
</div>
</aside>
);
}
function Topbar({ staff }: { staff: { id: number; username: string; rank: number } }) {
async function Topbar({ staff }: { staff: { id: number; username: string; rank: number } }) {
const t = await getTranslations("pages.admin.nav");
return (
<header className="flex items-center justify-between gap-4 bg-[var(--color-surface)] border border-[var(--border)] rounded-2xl px-5 py-3 mb-5 shadow-card">
<div className="flex items-center gap-3">
<h2 className="m-0 text-base font-extrabold text-[var(--color-text)]">Housekeeping</h2>
<h2 className="m-0 text-base font-extrabold text-[var(--color-text)]">{t("housekeeping")}</h2>
<span className="hidden sm:inline-block w-px h-5 bg-[var(--border)]" />
<span className="hidden sm:inline text-xs text-[var(--color-text-muted)]">
Hotel management panel
{t("hotelManagementPanel")}
</span>
</div>
<div className="flex items-center gap-3">
@@ -166,7 +175,7 @@ function Topbar({ staff }: { staff: { id: number; username: string; rank: number
<strong className="text-[var(--color-text)]">{staff.username}</strong>
</span>
<span className="inline-flex items-center gap-1.5 text-[0.6rem] font-bold uppercase tracking-wider text-[#1a1a2e] bg-[var(--color-primary)] rounded-full px-2.5 py-1">
rank {staff.rank}
{t("rankLabel", { rank: staff.rank })}
</span>
</div>
</header>