UI: i18n foundation (en/ru/de/fr/es), language picker, Shell/Welcome/Overview translated

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ДмитрийandClaude Sonnet 5.5 committed 2026-09-30 11:33:09 +05:00
1 parent c49d69df21
commit 0a9be3d800
11 files changed
+696 -56

No files matched your search

+34 -30
View File
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
import { Loader2 } from "lucide-react";
import { api, asUiError, type ClientInfo, type Human, type Population, type ServerSummary, type ServiceStatus, type StatusView } from "@/lib/api";
import { cn, formatUptime } from "@/lib/utils";
import { useHuman, useT } from "@/i18n";
import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
@@ -9,6 +10,7 @@ type Action = "starting" | "stopping" | "restarting" | null;
type Failure = { human: Human; technical: string };
function Row({ label, s }: { label: string; s: ServiceStatus }) {
const t = useT();
const running = s.state === "running";
const starting = s.state === "starting";
return (
@@ -25,13 +27,15 @@ function Row({ label, s }: { label: string; s: ServiceStatus }) {
running ? "bg-ok" : starting ? "animate-[pulse-dot_1.2s_ease-in-out_infinite] bg-warn" : "bg-muted/50",
)}
/>
{running ? "Running" : starting ? "Starting…" : "Stopped"}
{running ? t("status.running") : starting ? t("status.starting") : t("status.stopped")}
</span>
</div>
);
}
export function Overview({ server, onForget }: { server: ServerSummary; onForget: () => Promise<void> }) {
const t = useT();
const human = useHuman();
const [status, setStatus] = useState<StatusView | null>(null);
const [action, setAction] = useState<Action>(null);
const [failure, setFailure] = useState<Failure | null>(null);
@@ -104,14 +108,14 @@ export function Overview({ server, onForget }: { server: ServerSummary; onForget
}
}
if (!status) return <p className="text-muted">Checking your server…</p>;
if (!status) return <p className="text-muted">{t("overview.checking")}</p>;
if (!status.path_exists) {
return (
<div className="max-w-xl">
<h1 className="text-2xl font-semibold">Server folder not found</h1>
<p className="mt-2 text-muted">{server.path} is missing or was moved.</p>
<h1 className="text-2xl font-semibold">{t("overview.missingTitle")}</h1>
<p className="mt-2 text-muted">{t("overview.missingText", { path: server.path })}</p>
<Button className="mt-4" onClick={() => void onForget()}>
Remove from Manager (no files are deleted)
{t("overview.forget")}
</Button>
</div>
);
@@ -126,13 +130,13 @@ export function Overview({ server, onForget }: { server: ServerSummary; onForget
const headline = transitioning
? action === "stopping"
? "Stopping…"
: "Starting…"
? t("status.stopping")
: t("status.starting")
: running
? "Online"
? t("status.online")
: anyUp
? "Needs attention"
: "Offline";
? t("status.attention")
: t("status.offline");
const tone = transitioning ? "text-warn" : running ? "text-ok" : anyUp ? "text-warn" : "text-muted";
return (
@@ -141,7 +145,7 @@ export function Overview({ server, onForget }: { server: ServerSummary; onForget
<p className="selectable mt-0.5 text-xs text-muted">{server.path}</p>
<Card className="mt-6 p-7">
<div className="mb-1 text-xs font-medium uppercase tracking-[0.14em] text-muted">Server</div>
<div className="mb-1 text-xs font-medium uppercase tracking-[0.14em] text-muted">{t("overview.server")}</div>
<div className={cn("flex items-center gap-3 text-3xl font-semibold", tone)} role="status" aria-live="polite">
<span
aria-hidden
@@ -151,19 +155,19 @@ export function Overview({ server, onForget }: { server: ServerSummary; onForget
</div>
<div className="mt-5 divide-y divide-line border-y border-line">
<Row label="Database" s={mysql} />
<Row label="Auth server" s={auth} />
<Row label="World server" s={world} />
<Row label={t("overview.database")} s={mysql} />
<Row label={t("overview.auth")} s={auth} />
<Row label={t("overview.world")} s={world} />
</div>
<dl className="mt-4 grid grid-cols-2 gap-4 text-sm">
<div>
<dt className="text-muted">Uptime</dt>
<dt className="text-muted">{t("overview.uptime")}</dt>
<dd className="mt-0.5 text-lg">{world.state === "running" ? formatUptime(world.uptime_secs) : "—"}</dd>
</div>
<div>
<dt className="text-muted">Players online</dt>
<dd className="mt-0.5 text-lg">{pop ? `${pop.players_online}` : "—"}{pop && pop.bots_online > 0 ? <span className="ml-2 text-sm text-muted">+ {pop.bots_online} companions</span> : null}</dd>
<dt className="text-muted">{t("overview.players")}</dt>
<dd className="mt-0.5 text-lg">{pop ? `${pop.players_online}` : "—"}{pop && pop.bots_online > 0 ? <span className="ml-2 text-sm text-muted">{t("overview.companions", { n: pop.bots_online })}</span> : null}</dd>
</div>
</dl>
@@ -171,60 +175,60 @@ export function Overview({ server, onForget }: { server: ServerSummary; onForget
{running ? (
<Button variant="secondary" size="xl" disabled={transitioning} onClick={() => run("stopping")} className="min-w-56">
{transitioning && <Loader2 className="h-5 w-5 animate-spin" aria-hidden />}
STOP SERVER
{t("btn.stop")}
</Button>
) : (
<Button variant="primary" size="xl" disabled={transitioning} onClick={() => run("starting")} className="min-w-56">
{transitioning && <Loader2 className="h-5 w-5 animate-spin" aria-hidden />}
{transitioning ? (action === "stopping" ? "STOPPING…" : "STARTING…") : "START SERVER"}
{transitioning ? (action === "stopping" ? t("btn.stoppingCaps") : t("btn.startingCaps")) : t("btn.start")}
</Button>
)}
{running && (
<Button variant="ghost" size="sm" disabled={transitioning} onClick={() => run("restarting")}>
Restart
{t("btn.restart")}
</Button>
)}
{anyUp && !running && (
<Button variant="ghost" size="sm" disabled={transitioning} onClick={() => run("stopping")}>
Stop
{t("btn.stopSmall")}
</Button>
)}
{client && (
<Button variant={running ? "primary" : "secondary"} size="xl" disabled={transitioning || playing} onClick={() => void play()} className="ml-auto min-w-40">
{playing && <Loader2 className="h-5 w-5 animate-spin" aria-hidden />}
{running ? "PLAY" : "START & PLAY"}
{running ? t("btn.play") : t("btn.startPlay")}
</Button>
)}
</div>
{anyUp && !running && !transitioning && (
<p className="mt-3 text-sm text-muted">Some parts are running. Press Start to bring up the rest, or Stop to shut everything down.</p>
<p className="mt-3 text-sm text-muted">{t("overview.partial")}</p>
)}
</Card>
{conflict && !anyUp && (
<Card className="mt-4 border-warn/40 p-4" role="alert">
<p className="font-medium text-warn">A port this server needs is already in use</p>
<p className="font-medium text-warn">{t("overview.portTitle")}</p>
<p className="mt-1 text-sm text-muted">
Port {conflict.port} is used by another program{conflict.exe ? ` (${conflict.exe})` : ""}.
{t("overview.portText", { port: conflict.port, exe: conflict.exe ? ` (${conflict.exe})` : "" })}
</p>
</Card>
)}
{failure && (
<Card className="mt-4 border-bad/40 p-5" role="alert">
<p className="font-medium text-bad">{failure.human.title}</p>
<p className="mt-1 text-sm text-muted">{failure.human.message}</p>
<p className="font-medium text-bad">{human(failure.human).title}</p>
<p className="mt-1 text-sm text-muted">{human(failure.human).message}</p>
<div className="mt-3 flex gap-2">
<Button size="sm" onClick={() => setShowDetails((v) => !v)}>
{showDetails ? "Hide details" : "View details"}
{showDetails ? t("common.hideDetails") : t("common.viewDetails")}
</Button>
<Button size="sm" variant="ghost" onClick={() => void navigator.clipboard.writeText(failure.technical)}>
Copy error
{t("common.copyError")}
</Button>
</div>
{showDetails && (
<pre className="mt-3 max-h-56 overflow-auto whitespace-pre-wrap rounded bg-black/40 p-3 text-xs text-muted">
{failure.technical || "(no output)"}
{failure.technical || t("common.noOutput")}
</pre>
)}
</Card>
+21 -2
View File
@@ -8,6 +8,7 @@ import { Card } from "@/components/ui/card";
import { ClientCard } from "@/screens/ClientCard";
import { DiagnosticsCard } from "@/screens/DiagnosticsCard";
import { AboutCard } from "@/screens/AboutCard";
import { LOCALES, useI18n } from "@/i18n";
const ACTION_TEXT: Record<string, string> = {
create: "New file",
@@ -22,6 +23,7 @@ function mb(bytes: number) {
}
export function SettingsHome({ serverId }: { serverId: string }) {
const { t, locale, setLocale } = useI18n();
const [preview, setPreview] = useState<UpdatePreview | null>(null);
const [pending, setPending] = useState<UpdateTxn | null>(null);
const [busy, setBusy] = useState<"check" | "update" | "rollback" | null>(null);
@@ -96,8 +98,8 @@ export function SettingsHome({ serverId }: { serverId: string }) {
return (
<div className="max-w-2xl">
<h1 className="text-2xl font-semibold">Settings</h1>
<p className="mt-1 text-muted">How does Manager behave?</p>
<h1 className="text-2xl font-semibold">{t("settings.title")}</h1>
<p className="mt-1 text-muted">{t("q.settings")}</p>
{pending && (
<Card className="mt-6 border-warn/40 p-5" role="alert">
@@ -113,6 +115,23 @@ export function SettingsHome({ serverId }: { serverId: string }) {
</Card>
)}
<Card className="mt-6 p-6">
<h2 className="font-semibold">{t("settings.language")}</h2>
<p className="mt-1 text-sm text-muted">{t("settings.languageHint")}</p>
<select
aria-label={t("settings.language")}
value={locale}
onChange={(e) => setLocale(e.target.value as typeof locale)}
className="mt-3 rounded-md border border-line bg-bg px-3 py-2 text-sm outline-none focus:border-gold"
>
{LOCALES.map((l) => (
<option key={l.id} value={l.id}>
{l.name}
</option>
))}
</select>
</Card>
<ClientCard serverId={serverId} />
<DiagnosticsCard serverId={serverId} />
+18 -16
View File
@@ -1,6 +1,7 @@
import { useState } from "react";
import { Archive, Bot, Gauge, Globe, Server, Settings, Terminal, Users, type LucideIcon } from "lucide-react";
import { type ServerSummary } from "@/lib/api";
import { useT, type Key } from "@/i18n";
import { cn } from "@/lib/utils";
import { Overview } from "@/screens/Overview";
import { Placeholder } from "@/screens/Placeholder";
@@ -14,15 +15,15 @@ import { Button } from "@/components/ui/button";
type Page = "overview" | "bots" | "server" | "players" | "friends" | "backups" | "console" | "settings";
const NAV: { id: Page; label: string; icon: LucideIcon; question: string }[] = [
{ id: "overview", label: "Overview", icon: Gauge, question: "Is my server running?" },
{ id: "bots", label: "Bots", icon: Bot, question: "How are my bots configured?" },
{ id: "server", label: "Server", icon: Server, question: "How does my server behave?" },
{ id: "players", label: "Players", icon: Users, question: "Who is playing right now?" },
{ id: "friends", label: "Play with Friends", icon: Globe, question: "How can my friend join?" },
{ id: "backups", label: "Backups", icon: Archive, question: "Is my data safe?" },
{ id: "console", label: "Console", icon: Terminal, question: "What is the server doing?" },
{ id: "settings", label: "Settings", icon: Settings, question: "How does Manager behave?" },
const NAV: { id: Page; label: Key; icon: LucideIcon; question: Key }[] = [
{ id: "overview", label: "nav.overview", icon: Gauge, question: "q.overview" },
{ id: "bots", label: "nav.bots", icon: Bot, question: "q.bots" },
{ id: "server", label: "nav.server", icon: Server, question: "q.server" },
{ id: "players", label: "nav.players", icon: Users, question: "q.players" },
{ id: "friends", label: "nav.friends", icon: Globe, question: "q.friends" },
{ id: "backups", label: "nav.backups", icon: Archive, question: "q.backups" },
{ id: "console", label: "nav.console", icon: Terminal, question: "q.console" },
{ id: "settings", label: "nav.settings", icon: Settings, question: "q.settings" },
];
export function Shell(props: {
@@ -32,14 +33,15 @@ export function Shell(props: {
onAddAnother: () => void;
onForget: (id: string) => Promise<void>;
}) {
const t = useT();
const [page, setPage] = useState<Page>("overview");
const server = props.servers.find((s) => s.id === props.activeId)!;
const current = NAV.find((n) => n.id === page)!;
return (
<div className="flex h-full">
<nav className="flex w-60 shrink-0 flex-col border-r border-line bg-[#0b0c0e] p-3" aria-label="Main">
<div className="px-3 pb-4 pt-2 text-sm font-semibold tracking-wide text-gold">CoA Server Manager</div>
<nav className="flex w-60 shrink-0 flex-col border-r border-line bg-[#0b0c0e] p-3" aria-label={t("nav.main")}>
<div className="px-3 pb-4 pt-2 text-sm font-semibold tracking-wide text-gold">{t("app.name")}</div>
<ul className="flex flex-col gap-0.5">
{NAV.map(({ id, label, icon: Icon }) => (
<li key={id}>
@@ -52,7 +54,7 @@ export function Shell(props: {
)}
>
<Icon className={cn("h-[18px] w-[18px]", page === id && "text-gold")} aria-hidden />
{label}
{t(label)}
</button>
</li>
))}
@@ -64,7 +66,7 @@ export function Shell(props: {
className="mb-2 w-full rounded-md border border-line bg-card px-2 py-2 text-sm"
value={props.activeId}
onChange={(e) => props.onSelect(e.target.value)}
aria-label="Server"
aria-label={t("nav.serverPicker")}
>
{props.servers.map((s) => (
<option key={s.id} value={s.id}>
@@ -74,7 +76,7 @@ export function Shell(props: {
</select>
)}
<Button variant="ghost" size="sm" className="w-full justify-start" onClick={props.onAddAnother}>
Manage another server
{t("nav.addAnother")}
</Button>
</div>
</nav>
@@ -83,7 +85,7 @@ export function Shell(props: {
{page === "overview" ? (
<Overview key={server.id} server={server} onForget={() => props.onForget(server.id)} />
) : page === "bots" || page === "server" ? (
<SettingsPage key={`${server.id}-${page}`} serverId={server.id} scope={page} title={current.label} question={current.question} />
<SettingsPage key={`${server.id}-${page}`} serverId={server.id} scope={page} title={t(current.label)} question={t(current.question)} />
) : page === "console" ? (
<ConsolePage key={server.id} serverId={server.id} />
) : page === "friends" ? (
@@ -95,7 +97,7 @@ export function Shell(props: {
) : page === "backups" ? (
<BackupsPage key={server.id} serverId={server.id} />
) : (
<Placeholder title={current.label} question={current.question} />
<Placeholder title={t(current.label)} question={t(current.question)} />
)}
</main>
</div>
+9 -7
View File
@@ -1,12 +1,14 @@
import { FolderSearch, Download } from "lucide-react";
import { useT } from "@/i18n";
export function Welcome({ onImport, onInstall, onBack }: { onImport: () => void; onInstall: () => void; onBack?: () => void }) {
const t = useT();
return (
<main className="flex h-full flex-col items-center justify-center px-8">
<div className="mb-10 text-center">
<div className="mx-auto mb-5 h-12 w-12 rounded-full border-2 border-gold/80 bg-card-2" aria-hidden />
<h1 className="text-3xl font-semibold tracking-tight">Welcome to CoA Server Manager</h1>
<p className="mt-2 text-muted">Run your own Conquest of Azeroth server — no technical knowledge needed.</p>
<h1 className="text-3xl font-semibold tracking-tight">{t("welcome.title")}</h1>
<p className="mt-2 text-muted">{t("welcome.subtitle")}</p>
</div>
<div className="grid w-full max-w-3xl grid-cols-2 gap-5">
@@ -15,8 +17,8 @@ export function Welcome({ onImport, onInstall, onBack }: { onImport: () => void;
className="cursor-pointer rounded-card border border-line bg-card/90 p-7 text-left shadow-[0_8px_30px_rgb(0_0_0/0.28)] transition-colors hover:border-gold/60"
>
<Download className="mb-4 h-7 w-7 text-gold" aria-hidden />
<h2 className="text-lg font-semibold">Install new server</h2>
<p className="mt-1 text-sm text-muted">One-click setup with everything included.</p>
<h2 className="text-lg font-semibold">{t("welcome.install.title")}</h2>
<p className="mt-1 text-sm text-muted">{t("welcome.install.text")}</p>
</button>
<button
@@ -24,15 +26,15 @@ export function Welcome({ onImport, onInstall, onBack }: { onImport: () => void;
className="cursor-pointer rounded-card border border-line bg-card/90 p-7 text-left shadow-[0_8px_30px_rgb(0_0_0/0.28)] transition-colors hover:border-gold/60"
>
<FolderSearch className="mb-4 h-7 w-7 text-gold" aria-hidden />
<h2 className="text-lg font-semibold">I already have a server</h2>
<h2 className="text-lg font-semibold">{t("welcome.import.title")}</h2>
<p className="mt-1 text-sm text-muted">
Add your existing server. It is only read — nothing is changed.
{t("welcome.import.text")}
</p>
</button>
</div>
{onBack && (
<button onClick={onBack} className="mt-8 cursor-pointer text-sm text-muted hover:text-ink">
Back to my servers
{t("welcome.back")}
</button>
)}
</main>