mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-26 03:25:56 +00:00
UI: translate Console page
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3039906411
commit
6ae1fccba8
6 files changed
+114
-26
No files matched your search
@@ -318,6 +318,23 @@ const de: Partial<Record<keyof typeof en, string>> = {
|
|||||||
"fr.copy": "Verbindungsdaten kopieren",
|
"fr.copy": "Verbindungsdaten kopieren",
|
||||||
"fr.pkg": "Freundepaket erstellen (zip)",
|
"fr.pkg": "Freundepaket erstellen (zip)",
|
||||||
"fr.pkgSaved": "Gespeichert: {path}",
|
"fr.pkgSaved": "Gespeichert: {path}",
|
||||||
|
|
||||||
|
// Console
|
||||||
|
"con.title": "Konsole",
|
||||||
|
"con.tab.world": "Welt",
|
||||||
|
"con.tab.auth": "Anmeldung",
|
||||||
|
"con.tab.database": "Datenbank",
|
||||||
|
"con.tab.manager": "Manager",
|
||||||
|
"con.searchLabel": "Protokoll durchsuchen",
|
||||||
|
"con.search": "Suchen …",
|
||||||
|
"con.follow": "Mitverfolgen",
|
||||||
|
"con.copied": "Kopiert",
|
||||||
|
"con.copyErrors": "Fehler kopieren",
|
||||||
|
"con.empty": "Nichts anzuzeigen.",
|
||||||
|
"con.commandsNote": "Befehle gehen direkt an den laufenden Weltserver. Riskante (Herunterfahren, Löschen, Sperren) verlangen eine Bestätigung.",
|
||||||
|
"con.commandLabel": "Befehl",
|
||||||
|
"con.send": "Senden",
|
||||||
|
"con.confirmRisky": "„{cmd}“ kann Dinge herunterfahren oder viele Datensätze ändern. Trotzdem senden?",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default de;
|
export default de;
|
||||||
@@ -318,6 +318,23 @@ const en = {
|
|||||||
"fr.copy": "Copy connection info",
|
"fr.copy": "Copy connection info",
|
||||||
"fr.pkg": "Create friend package (zip)",
|
"fr.pkg": "Create friend package (zip)",
|
||||||
"fr.pkgSaved": "Saved: {path}",
|
"fr.pkgSaved": "Saved: {path}",
|
||||||
|
|
||||||
|
// Console
|
||||||
|
"con.title": "Console",
|
||||||
|
"con.tab.world": "World",
|
||||||
|
"con.tab.auth": "Auth",
|
||||||
|
"con.tab.database": "Database",
|
||||||
|
"con.tab.manager": "Manager",
|
||||||
|
"con.searchLabel": "Search the log",
|
||||||
|
"con.search": "Search…",
|
||||||
|
"con.follow": "Follow",
|
||||||
|
"con.copied": "Copied",
|
||||||
|
"con.copyErrors": "Copy errors",
|
||||||
|
"con.empty": "Nothing to show.",
|
||||||
|
"con.commandsNote": "Commands go straight to the running world server. Risky ones (shutdown, deleting or banning) ask for confirmation.",
|
||||||
|
"con.commandLabel": "Command",
|
||||||
|
"con.send": "Send",
|
||||||
|
"con.confirmRisky": "“{cmd}” can shut things down or change many records. Send it anyway?",
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export default en;
|
export default en;
|
||||||
@@ -318,6 +318,23 @@ const es: Partial<Record<keyof typeof en, string>> = {
|
|||||||
"fr.copy": "Copiar datos de conexión",
|
"fr.copy": "Copiar datos de conexión",
|
||||||
"fr.pkg": "Crear paquete para amigo (zip)",
|
"fr.pkg": "Crear paquete para amigo (zip)",
|
||||||
"fr.pkgSaved": "Guardado: {path}",
|
"fr.pkgSaved": "Guardado: {path}",
|
||||||
|
|
||||||
|
// Console
|
||||||
|
"con.title": "Consola",
|
||||||
|
"con.tab.world": "Mundo",
|
||||||
|
"con.tab.auth": "Acceso",
|
||||||
|
"con.tab.database": "Base de datos",
|
||||||
|
"con.tab.manager": "Manager",
|
||||||
|
"con.searchLabel": "Buscar en el registro",
|
||||||
|
"con.search": "Buscar…",
|
||||||
|
"con.follow": "Seguir",
|
||||||
|
"con.copied": "Copiado",
|
||||||
|
"con.copyErrors": "Copiar errores",
|
||||||
|
"con.empty": "Nada que mostrar.",
|
||||||
|
"con.commandsNote": "Los comandos van directamente al servidor del mundo en ejecución. Los arriesgados (apagar, borrar o vetar) piden confirmación.",
|
||||||
|
"con.commandLabel": "Comando",
|
||||||
|
"con.send": "Enviar",
|
||||||
|
"con.confirmRisky": "«{cmd}» puede apagar cosas o cambiar muchos registros. ¿Enviarlo de todos modos?",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default es;
|
export default es;
|
||||||
@@ -318,6 +318,23 @@ const fr: Partial<Record<keyof typeof en, string>> = {
|
|||||||
"fr.copy": "Copier les informations de connexion",
|
"fr.copy": "Copier les informations de connexion",
|
||||||
"fr.pkg": "Créer le paquet pour ami (zip)",
|
"fr.pkg": "Créer le paquet pour ami (zip)",
|
||||||
"fr.pkgSaved": "Enregistré : {path}",
|
"fr.pkgSaved": "Enregistré : {path}",
|
||||||
|
|
||||||
|
// Console
|
||||||
|
"con.title": "Console",
|
||||||
|
"con.tab.world": "Monde",
|
||||||
|
"con.tab.auth": "Connexion",
|
||||||
|
"con.tab.database": "Base de données",
|
||||||
|
"con.tab.manager": "Manager",
|
||||||
|
"con.searchLabel": "Rechercher dans le journal",
|
||||||
|
"con.search": "Rechercher…",
|
||||||
|
"con.follow": "Suivre",
|
||||||
|
"con.copied": "Copié",
|
||||||
|
"con.copyErrors": "Copier les erreurs",
|
||||||
|
"con.empty": "Rien à afficher.",
|
||||||
|
"con.commandsNote": "Les commandes vont directement au serveur de monde en cours d’exécution. Les commandes risquées (arrêt, suppression, bannissement) demandent confirmation.",
|
||||||
|
"con.commandLabel": "Commande",
|
||||||
|
"con.send": "Envoyer",
|
||||||
|
"con.confirmRisky": "« {cmd} » peut tout arrêter ou modifier de nombreux enregistrements. L’envoyer quand même ?",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default fr;
|
export default fr;
|
||||||
@@ -318,6 +318,23 @@ const ru: Partial<Record<keyof typeof en, string>> = {
|
|||||||
"fr.copy": "Скопировать данные подключения",
|
"fr.copy": "Скопировать данные подключения",
|
||||||
"fr.pkg": "Создать пакет для друга (zip)",
|
"fr.pkg": "Создать пакет для друга (zip)",
|
||||||
"fr.pkgSaved": "Сохранено: {path}",
|
"fr.pkgSaved": "Сохранено: {path}",
|
||||||
|
|
||||||
|
// Console
|
||||||
|
"con.title": "Консоль",
|
||||||
|
"con.tab.world": "Мир",
|
||||||
|
"con.tab.auth": "Вход",
|
||||||
|
"con.tab.database": "База данных",
|
||||||
|
"con.tab.manager": "Менеджер",
|
||||||
|
"con.searchLabel": "Поиск по журналу",
|
||||||
|
"con.search": "Поиск…",
|
||||||
|
"con.follow": "Следить",
|
||||||
|
"con.copied": "Скопировано",
|
||||||
|
"con.copyErrors": "Скопировать ошибки",
|
||||||
|
"con.empty": "Показывать нечего.",
|
||||||
|
"con.commandsNote": "Команды отправляются прямо на запущенный игровой сервер. Рискованные (выключение, удаление, бан) требуют подтверждения.",
|
||||||
|
"con.commandLabel": "Команда",
|
||||||
|
"con.send": "Отправить",
|
||||||
|
"con.confirmRisky": "Команда «{cmd}» может что-то выключить или изменить много записей. Всё равно отправить?",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ru;
|
export default ru;
|
||||||
+29
-26
@@ -3,17 +3,20 @@ import { api, asUiError, type ConsoleLine, type ConsoleSource, type UiError } fr
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Card } from "@/components/ui/card";
|
import { Card } from "@/components/ui/card";
|
||||||
|
import { useHuman, useT, type Key } from "@/i18n";
|
||||||
|
|
||||||
const TABS: { id: ConsoleSource; label: string }[] = [
|
const TABS: { id: ConsoleSource; label: Key }[] = [
|
||||||
{ id: "world", label: "World" },
|
{ id: "world", label: "con.tab.world" },
|
||||||
{ id: "auth", label: "Auth" },
|
{ id: "auth", label: "con.tab.auth" },
|
||||||
{ id: "database", label: "Database" },
|
{ id: "database", label: "con.tab.database" },
|
||||||
{ id: "manager", label: "Manager" },
|
{ id: "manager", label: "con.tab.manager" },
|
||||||
];
|
];
|
||||||
|
|
||||||
const TONE = { info: "text-ink/80", warn: "text-warn", error: "text-bad" } as const;
|
const TONE = { info: "text-ink/80", warn: "text-warn", error: "text-bad" } as const;
|
||||||
|
|
||||||
export function ConsolePage({ serverId }: { serverId: string }) {
|
export function ConsolePage({ serverId }: { serverId: string }) {
|
||||||
|
const t = useT();
|
||||||
|
const human = useHuman();
|
||||||
const [tab, setTab] = useState<ConsoleSource>("world");
|
const [tab, setTab] = useState<ConsoleSource>("world");
|
||||||
const [filter, setFilter] = useState("");
|
const [filter, setFilter] = useState("");
|
||||||
const [lines, setLines] = useState<ConsoleLine[]>([]);
|
const [lines, setLines] = useState<ConsoleLine[]>([]);
|
||||||
@@ -38,8 +41,8 @@ export function ConsolePage({ serverId }: { serverId: string }) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void load();
|
void load();
|
||||||
if (!live) return;
|
if (!live) return;
|
||||||
const t = setInterval(load, 2000);
|
const iv = setInterval(load, 2000);
|
||||||
return () => clearInterval(t);
|
return () => clearInterval(iv);
|
||||||
}, [load, live]);
|
}, [load, live]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -51,8 +54,8 @@ export function ConsolePage({ serverId }: { serverId: string }) {
|
|||||||
setReply(null);
|
setReply(null);
|
||||||
try {
|
try {
|
||||||
const risk = await api.consoleRisk(cmd);
|
const risk = await api.consoleRisk(cmd);
|
||||||
if (risk === "dangerous" && !window.confirm(`“${cmd}” can shut things down or change many records. Send it anyway?`)) return;
|
if (risk === "dangerous" && !window.confirm(t("con.confirmRisky", { cmd }))) return;
|
||||||
setReply((await api.consoleCommand(serverId, cmd, risk === "dangerous")) || "(no output)");
|
setReply((await api.consoleCommand(serverId, cmd, risk === "dangerous")) || t("common.noOutput"));
|
||||||
setCmd("");
|
setCmd("");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setError(asUiError(e));
|
setError(asUiError(e));
|
||||||
@@ -63,32 +66,32 @@ export function ConsolePage({ serverId }: { serverId: string }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full max-w-4xl flex-col">
|
<div className="flex h-full max-w-4xl flex-col">
|
||||||
<h1 className="text-2xl font-semibold">Console</h1>
|
<h1 className="text-2xl font-semibold">{t("con.title")}</h1>
|
||||||
<p className="mt-1 text-muted">What is the server doing?</p>
|
<p className="mt-1 text-muted">{t("q.console")}</p>
|
||||||
|
|
||||||
<div className="mt-4 flex flex-wrap items-center gap-2">
|
<div className="mt-4 flex flex-wrap items-center gap-2">
|
||||||
<div className="flex gap-1" role="tablist">
|
<div className="flex gap-1" role="tablist">
|
||||||
{TABS.map((t) => (
|
{TABS.map((tb) => (
|
||||||
<button
|
<button
|
||||||
key={t.id}
|
key={tb.id}
|
||||||
role="tab"
|
role="tab"
|
||||||
aria-selected={tab === t.id}
|
aria-selected={tab === tb.id}
|
||||||
onClick={() => setTab(t.id)}
|
onClick={() => setTab(tb.id)}
|
||||||
className={cn("cursor-pointer rounded-md px-3 py-1.5 text-sm", tab === t.id ? "bg-white/10 text-ink" : "text-muted hover:text-ink")}
|
className={cn("cursor-pointer rounded-md px-3 py-1.5 text-sm", tab === tb.id ? "bg-white/10 text-ink" : "text-muted hover:text-ink")}
|
||||||
>
|
>
|
||||||
{t.label}
|
{t(tb.label)}
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<input
|
<input
|
||||||
aria-label="Search the log"
|
aria-label={t("con.searchLabel")}
|
||||||
placeholder="Search…"
|
placeholder={t("con.search")}
|
||||||
value={filter}
|
value={filter}
|
||||||
onChange={(e) => setFilter(e.target.value)}
|
onChange={(e) => setFilter(e.target.value)}
|
||||||
className="ml-auto w-56 rounded-md border border-line bg-bg px-3 py-1.5 text-sm outline-none focus:border-gold"
|
className="ml-auto w-56 rounded-md border border-line bg-bg px-3 py-1.5 text-sm outline-none focus:border-gold"
|
||||||
/>
|
/>
|
||||||
<label className="flex cursor-pointer items-center gap-1.5 text-sm text-muted">
|
<label className="flex cursor-pointer items-center gap-1.5 text-sm text-muted">
|
||||||
<input type="checkbox" checked={live} onChange={(e) => setLive(e.target.checked)} /> Follow
|
<input type="checkbox" checked={live} onChange={(e) => setLive(e.target.checked)} /> {t("con.follow")}
|
||||||
</label>
|
</label>
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
@@ -96,12 +99,12 @@ export function ConsolePage({ serverId }: { serverId: string }) {
|
|||||||
disabled={errors.length === 0}
|
disabled={errors.length === 0}
|
||||||
onClick={() => void navigator.clipboard.writeText(errors.slice(-20).join("\n")).then(() => { setCopied(true); setTimeout(() => setCopied(false), 1500); })}
|
onClick={() => void navigator.clipboard.writeText(errors.slice(-20).join("\n")).then(() => { setCopied(true); setTimeout(() => setCopied(false), 1500); })}
|
||||||
>
|
>
|
||||||
{copied ? "Copied" : "Copy errors"}
|
{copied ? t("con.copied") : t("con.copyErrors")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ref={box} className="selectable mt-3 min-h-64 flex-1 overflow-auto rounded-card border border-line bg-black/40 p-3 font-mono text-xs leading-5" role="log" aria-live="off">
|
<div ref={box} className="selectable mt-3 min-h-64 flex-1 overflow-auto rounded-card border border-line bg-black/40 p-3 font-mono text-xs leading-5" role="log" aria-live="off">
|
||||||
{missing ? <p className="text-muted">{missing}</p> : lines.length === 0 ? <p className="text-muted">Nothing to show.</p> : lines.map((l, i) => (
|
{missing ? <p className="text-muted">{missing}</p> : lines.length === 0 ? <p className="text-muted">{t("con.empty")}</p> : lines.map((l, i) => (
|
||||||
<div key={i} className={cn("whitespace-pre-wrap break-all", TONE[l.level])}>
|
<div key={i} className={cn("whitespace-pre-wrap break-all", TONE[l.level])}>
|
||||||
{l.level !== "info" && <span className="sr-only">{l.level}: </span>}
|
{l.level !== "info" && <span className="sr-only">{l.level}: </span>}
|
||||||
{l.text}
|
{l.text}
|
||||||
@@ -111,13 +114,13 @@ export function ConsolePage({ serverId }: { serverId: string }) {
|
|||||||
|
|
||||||
{tab === "world" && (
|
{tab === "world" && (
|
||||||
<Card className="mt-3 p-4">
|
<Card className="mt-3 p-4">
|
||||||
<p className="text-xs text-muted">Commands go straight to the running world server. Risky ones (shutdown, deleting or banning) ask for confirmation.</p>
|
<p className="text-xs text-muted">{t("con.commandsNote")}</p>
|
||||||
<form className="mt-2 flex gap-2" onSubmit={(e) => { e.preventDefault(); void send(); }}>
|
<form className="mt-2 flex gap-2" onSubmit={(e) => { e.preventDefault(); void send(); }}>
|
||||||
<input aria-label="Command" value={cmd} onChange={(e) => setCmd(e.target.value)} placeholder="server info" className="selectable flex-1 rounded-md border border-line bg-bg px-3 py-2 font-mono text-sm outline-none focus:border-gold" />
|
<input aria-label={t("con.commandLabel")} value={cmd} onChange={(e) => setCmd(e.target.value)} placeholder="server info" className="selectable flex-1 rounded-md border border-line bg-bg px-3 py-2 font-mono text-sm outline-none focus:border-gold" />
|
||||||
<Button variant="secondary" size="sm" type="submit" disabled={!cmd.trim()}>Send</Button>
|
<Button variant="secondary" size="sm" type="submit" disabled={!cmd.trim()}>{t("con.send")}</Button>
|
||||||
</form>
|
</form>
|
||||||
{reply && <pre className="selectable mt-2 max-h-40 overflow-auto whitespace-pre-wrap rounded bg-black/40 p-2 text-xs">{reply}</pre>}
|
{reply && <pre className="selectable mt-2 max-h-40 overflow-auto whitespace-pre-wrap rounded bg-black/40 p-2 text-xs">{reply}</pre>}
|
||||||
{error && <p className="mt-2 text-sm text-bad" role="alert">{error.human.code === "unknown" ? error.technical : error.human.message}</p>}
|
{error && <p className="mt-2 text-sm text-bad" role="alert">{error.human.code === "unknown" ? error.technical : human(error.human).message}</p>}
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user