mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-20 11:25:56 +00:00
UI: translate Diagnostics and About cards
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
488a1a45c6
commit
0b975a7c42
8 files changed
+168
-23
No files matched your search
+3
-3
@@ -42,10 +42,10 @@ export function lookup(locale: Locale, key: Key, vars?: Vars): string {
|
||||
}
|
||||
|
||||
/** Plural form: tries `key_<category>` (one/few/many/other) for the locale, then `key_other`, then `key`. */
|
||||
export function lookupPlural(locale: Locale, key: Key, n: number, vars?: Vars): string {
|
||||
export function lookupPlural(locale: Locale, key: string, n: number, vars?: Vars): string {
|
||||
const cat = new Intl.PluralRules(locale).select(n);
|
||||
const d = DICTS[locale];
|
||||
const text = d[`${key}_${cat}` as Key] ?? d[`${key}_other` as Key] ?? en[`${key}_${cat}` as Key] ?? en[`${key}_other` as Key] ?? en[key] ?? key;
|
||||
const text = d[`${key}_${cat}` as Key] ?? d[`${key}_other` as Key] ?? en[`${key}_${cat}` as Key] ?? en[`${key}_other` as Key] ?? en[key as Key] ?? key;
|
||||
return interpolate(text, { n, ...vars });
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ interface Ctx {
|
||||
locale: Locale;
|
||||
setLocale: (l: Locale) => void;
|
||||
t: (key: Key, vars?: Vars) => string;
|
||||
tn: (key: Key, n: number, vars?: Vars) => string;
|
||||
tn: (key: string, n: number, vars?: Vars) => string;
|
||||
}
|
||||
|
||||
const I18n = createContext<Ctx>({
|
||||
|
||||
@@ -198,6 +198,34 @@ const de: Partial<Record<keyof typeof en, string>> = {
|
||||
"client.updateAddon": "Begleiter-Addon aktualisieren",
|
||||
"client.addonNote": "Begleiter-Addon installiert. Andere Addons wurden nicht angetastet.",
|
||||
"client.changeFolder": "Ordner ändern …",
|
||||
|
||||
// Diagnostics
|
||||
"diag.title": "Diagnose",
|
||||
"diag.text": "Sucht nach häufigen Problemen. Es wird nichts verändert.",
|
||||
"diag.run": "Diagnose starten",
|
||||
"diag.verify": "Serverdateien prüfen",
|
||||
"diag.export": "Diagnosepaket exportieren",
|
||||
"diag.saved": "Für Fehlerberichte gespeichert: {path}",
|
||||
"diag.allGood": "Alles sieht gut aus.",
|
||||
"diag.problems_one": "{n} Punkt zum Prüfen",
|
||||
"diag.problems_few": "{n} Punkte zum Prüfen",
|
||||
"diag.problems_many": "{n} Punkte zum Prüfen",
|
||||
"diag.problems_other": "{n} Punkte zum Prüfen",
|
||||
"diag.word.ok": "OK",
|
||||
"diag.word.warn": "Achtung",
|
||||
"diag.word.fail": "Problem",
|
||||
"diag.filesOk": "Alle Programmdateien sind unversehrt.",
|
||||
"diag.filesDiffer": "{n} Programmdatei(en) weichen vom Installierten ab. Deine eigenen Dateien werden hier nie aufgeführt. „Nach Updates suchen“ stellt fehlende wieder her.",
|
||||
"diag.fileMissing": "fehlt",
|
||||
"diag.fileChanged": "geändert",
|
||||
|
||||
// About Manager
|
||||
"about.version": "Version {v}. Programmupdates verändern deinen Server nie.",
|
||||
"about.check": "Nach neuer Version suchen",
|
||||
"about.install": "{v} installieren und neu starten",
|
||||
"about.upToDate": "CoA Server Manager ist auf dem neuesten Stand.",
|
||||
"about.checkFailed": "Die Suche nach einer neuen Version ist fehlgeschlagen. Prüfe deine Internetverbindung und versuche es erneut.",
|
||||
"about.installFailed": "Das Update konnte nicht installiert werden. Dein Server wurde nicht angetastet.",
|
||||
};
|
||||
|
||||
export default de;
|
||||
@@ -198,6 +198,34 @@ const en = {
|
||||
"client.updateAddon": "Update companion addon",
|
||||
"client.addonNote": "Companion addon installed. Other addons were not touched.",
|
||||
"client.changeFolder": "Change folder…",
|
||||
|
||||
// Diagnostics
|
||||
"diag.title": "Diagnostics",
|
||||
"diag.text": "Looks for common problems. Nothing is changed.",
|
||||
"diag.run": "Run diagnostics",
|
||||
"diag.verify": "Check server files",
|
||||
"diag.export": "Export diagnostic package",
|
||||
"diag.saved": "Saved for bug reports: {path}",
|
||||
"diag.allGood": "Everything looks good.",
|
||||
"diag.problems_one": "{n} thing to look at",
|
||||
"diag.problems_few": "{n} things to look at",
|
||||
"diag.problems_many": "{n} things to look at",
|
||||
"diag.problems_other": "{n} things to look at",
|
||||
"diag.word.ok": "OK",
|
||||
"diag.word.warn": "Attention",
|
||||
"diag.word.fail": "Problem",
|
||||
"diag.filesOk": "All program files are intact.",
|
||||
"diag.filesDiffer": "{n} program file(s) differ from what was installed. Your own files are never listed here. \"Check for updates\" restores missing ones.",
|
||||
"diag.fileMissing": "missing",
|
||||
"diag.fileChanged": "changed",
|
||||
|
||||
// About Manager
|
||||
"about.version": "Version {v}. Updates to the program never change your server.",
|
||||
"about.check": "Check for a new version",
|
||||
"about.install": "Install {v} and restart",
|
||||
"about.upToDate": "CoA Server Manager is up to date.",
|
||||
"about.checkFailed": "Could not check for a new version. Check your internet connection and try again.",
|
||||
"about.installFailed": "The update could not be installed. Your server was not touched.",
|
||||
} as const;
|
||||
|
||||
export default en;
|
||||
@@ -198,6 +198,34 @@ const es: Partial<Record<keyof typeof en, string>> = {
|
||||
"client.updateAddon": "Actualizar addon de compañeros",
|
||||
"client.addonNote": "Addon de compañeros instalado. Los demás addons no se tocaron.",
|
||||
"client.changeFolder": "Cambiar carpeta…",
|
||||
|
||||
// Diagnostics
|
||||
"diag.title": "Diagnóstico",
|
||||
"diag.text": "Busca problemas comunes. No se cambia nada.",
|
||||
"diag.run": "Ejecutar diagnóstico",
|
||||
"diag.verify": "Comprobar archivos del servidor",
|
||||
"diag.export": "Exportar paquete de diagnóstico",
|
||||
"diag.saved": "Guardado para informes de errores: {path}",
|
||||
"diag.allGood": "Todo parece correcto.",
|
||||
"diag.problems_one": "{n} cosa que revisar",
|
||||
"diag.problems_few": "{n} cosas que revisar",
|
||||
"diag.problems_many": "{n} cosas que revisar",
|
||||
"diag.problems_other": "{n} cosas que revisar",
|
||||
"diag.word.ok": "Correcto",
|
||||
"diag.word.warn": "Atención",
|
||||
"diag.word.fail": "Problema",
|
||||
"diag.filesOk": "Todos los archivos del programa están intactos.",
|
||||
"diag.filesDiffer": "{n} archivo(s) del programa difieren de lo instalado. Tus propios archivos nunca aparecen aquí. «Buscar actualizaciones» restaura los que faltan.",
|
||||
"diag.fileMissing": "falta",
|
||||
"diag.fileChanged": "modificado",
|
||||
|
||||
// About Manager
|
||||
"about.version": "Versión {v}. Las actualizaciones del programa nunca cambian tu servidor.",
|
||||
"about.check": "Buscar una versión nueva",
|
||||
"about.install": "Instalar {v} y reiniciar",
|
||||
"about.upToDate": "CoA Server Manager está actualizado.",
|
||||
"about.checkFailed": "No se pudo buscar una versión nueva. Comprueba tu conexión a internet e inténtalo de nuevo.",
|
||||
"about.installFailed": "No se pudo instalar la actualización. Tu servidor no se ha tocado.",
|
||||
};
|
||||
|
||||
export default es;
|
||||
@@ -198,6 +198,34 @@ const fr: Partial<Record<keyof typeof en, string>> = {
|
||||
"client.updateAddon": "Mettre à jour l’addon des compagnons",
|
||||
"client.addonNote": "Addon des compagnons installé. Les autres addons n’ont pas été touchés.",
|
||||
"client.changeFolder": "Changer de dossier…",
|
||||
|
||||
// Diagnostics
|
||||
"diag.title": "Diagnostic",
|
||||
"diag.text": "Recherche les problèmes courants. Rien n’est modifié.",
|
||||
"diag.run": "Lancer le diagnostic",
|
||||
"diag.verify": "Vérifier les fichiers du serveur",
|
||||
"diag.export": "Exporter le paquet de diagnostic",
|
||||
"diag.saved": "Enregistré pour les rapports de bogue : {path}",
|
||||
"diag.allGood": "Tout semble en ordre.",
|
||||
"diag.problems_one": "{n} point à examiner",
|
||||
"diag.problems_few": "{n} points à examiner",
|
||||
"diag.problems_many": "{n} points à examiner",
|
||||
"diag.problems_other": "{n} points à examiner",
|
||||
"diag.word.ok": "OK",
|
||||
"diag.word.warn": "Attention",
|
||||
"diag.word.fail": "Problème",
|
||||
"diag.filesOk": "Tous les fichiers du programme sont intacts.",
|
||||
"diag.filesDiffer": "{n} fichier(s) du programme diffèrent de l’installation. Vos propres fichiers ne sont jamais listés ici. « Rechercher des mises à jour » restaure ceux qui manquent.",
|
||||
"diag.fileMissing": "manquant",
|
||||
"diag.fileChanged": "modifié",
|
||||
|
||||
// About Manager
|
||||
"about.version": "Version {v}. Les mises à jour du programme ne modifient jamais votre serveur.",
|
||||
"about.check": "Rechercher une nouvelle version",
|
||||
"about.install": "Installer {v} et redémarrer",
|
||||
"about.upToDate": "CoA Server Manager est à jour.",
|
||||
"about.checkFailed": "Impossible de rechercher une nouvelle version. Vérifiez votre connexion internet et réessayez.",
|
||||
"about.installFailed": "La mise à jour n’a pas pu être installée. Votre serveur n’a pas été touché.",
|
||||
};
|
||||
|
||||
export default fr;
|
||||
@@ -198,6 +198,34 @@ const ru: Partial<Record<keyof typeof en, string>> = {
|
||||
"client.updateAddon": "Обновить аддон компаньонов",
|
||||
"client.addonNote": "Аддон компаньонов установлен. Другие аддоны не затронуты.",
|
||||
"client.changeFolder": "Сменить папку…",
|
||||
|
||||
// Diagnostics
|
||||
"diag.title": "Диагностика",
|
||||
"diag.text": "Ищет типичные проблемы. Ничего не изменяется.",
|
||||
"diag.run": "Запустить диагностику",
|
||||
"diag.verify": "Проверить файлы сервера",
|
||||
"diag.export": "Экспортировать пакет диагностики",
|
||||
"diag.saved": "Сохранено для отчёта об ошибке: {path}",
|
||||
"diag.allGood": "Всё в порядке.",
|
||||
"diag.problems_one": "Стоит проверить: {n}",
|
||||
"diag.problems_few": "Стоит проверить: {n}",
|
||||
"diag.problems_many": "Стоит проверить: {n}",
|
||||
"diag.problems_other": "Стоит проверить: {n}",
|
||||
"diag.word.ok": "В порядке",
|
||||
"diag.word.warn": "Внимание",
|
||||
"diag.word.fail": "Проблема",
|
||||
"diag.filesOk": "Все файлы программы целы.",
|
||||
"diag.filesDiffer": "Файлов программы, отличающихся от установленных: {n}. Ваши собственные файлы здесь не показываются. «Проверить обновления» восстановит отсутствующие.",
|
||||
"diag.fileMissing": "отсутствует",
|
||||
"diag.fileChanged": "изменён",
|
||||
|
||||
// About Manager
|
||||
"about.version": "Версия {v}. Обновления программы никогда не меняют ваш сервер.",
|
||||
"about.check": "Проверить наличие новой версии",
|
||||
"about.install": "Установить {v} и перезапустить",
|
||||
"about.upToDate": "У вас последняя версия CoA Server Manager.",
|
||||
"about.checkFailed": "Не удалось проверить наличие новой версии. Проверьте подключение к интернету и повторите попытку.",
|
||||
"about.installFailed": "Не удалось установить обновление. Ваш сервер не затронут.",
|
||||
};
|
||||
|
||||
export default ru;
|
||||
@@ -5,8 +5,10 @@ import { relaunch } from "@tauri-apps/plugin-process";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card } from "@/components/ui/card";
|
||||
import { useT } from "@/i18n";
|
||||
|
||||
export function AboutCard() {
|
||||
const t = useT();
|
||||
const [version, setVersion] = useState("");
|
||||
const [update, setUpdate] = useState<Update | null>(null);
|
||||
const [busy, setBusy] = useState<"check" | "install" | null>(null);
|
||||
@@ -25,9 +27,9 @@ export function AboutCard() {
|
||||
try {
|
||||
const u = await check();
|
||||
setUpdate(u);
|
||||
if (!u) setNote("CoA Server Manager is up to date.");
|
||||
if (!u) setNote(t("about.upToDate"));
|
||||
} catch {
|
||||
setError("Could not check for a new version. Check your internet connection and try again.");
|
||||
setError(t("about.checkFailed"));
|
||||
} finally {
|
||||
setBusy(null);
|
||||
}
|
||||
@@ -49,24 +51,24 @@ export function AboutCard() {
|
||||
});
|
||||
await relaunch();
|
||||
} catch {
|
||||
setError("The update could not be installed. Your server was not touched.");
|
||||
setError(t("about.installFailed"));
|
||||
setBusy(null);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Card className="mt-6 p-6">
|
||||
<h2 className="font-semibold">CoA Server Manager</h2>
|
||||
<p className="mt-1 text-sm text-muted">Version {version || "…"}. Updates to the program never change your server.</p>
|
||||
<h2 className="font-semibold">{t("app.name")}</h2>
|
||||
<p className="mt-1 text-sm text-muted">{t("about.version", { v: version || "…" })}</p>
|
||||
<div className="mt-4 flex items-center gap-3">
|
||||
<Button size="sm" disabled={!!busy} onClick={() => void look()}>
|
||||
{busy === "check" && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}
|
||||
Check for a new version
|
||||
{t("about.check")}
|
||||
</Button>
|
||||
{update && (
|
||||
<Button size="sm" variant="primary" disabled={!!busy} onClick={() => void install()}>
|
||||
{busy === "install" && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}
|
||||
Install {update.version} and restart
|
||||
{t("about.install", { v: update.version })}
|
||||
</Button>
|
||||
)}
|
||||
{percent !== null && busy === "install" && <span className="text-sm text-muted" role="status">{percent}%</span>}
|
||||
|
||||
@@ -3,12 +3,15 @@ import { Check, Loader2, TriangleAlert, X } from "lucide-react";
|
||||
import { api, asUiError, type DiagCheck, type UiError } from "@/lib/api";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card } from "@/components/ui/card";
|
||||
import { useHuman, useI18n } from "@/i18n";
|
||||
|
||||
const ICON = { ok: Check, warn: TriangleAlert, fail: X } as const;
|
||||
const TONE = { ok: "text-ok", warn: "text-warn", fail: "text-bad" } as const;
|
||||
const WORD = { ok: "OK", warn: "Attention", fail: "Problem" } as const;
|
||||
const WORD = { ok: "diag.word.ok", warn: "diag.word.warn", fail: "diag.word.fail" } as const;
|
||||
|
||||
export function DiagnosticsCard({ serverId }: { serverId: string }) {
|
||||
const { t, tn } = useI18n();
|
||||
const human = useHuman();
|
||||
const [checks, setChecks] = useState<DiagCheck[] | null>(null);
|
||||
const [files, setFiles] = useState<{ path: string; kind: string }[] | null>(null);
|
||||
const [busy, setBusy] = useState<string | null>(null);
|
||||
@@ -32,24 +35,24 @@ export function DiagnosticsCard({ serverId }: { serverId: string }) {
|
||||
|
||||
return (
|
||||
<Card className="mt-6 p-6">
|
||||
<h2 className="font-semibold">Diagnostics</h2>
|
||||
<p className="mt-1 text-sm text-muted">Looks for common problems. Nothing is changed.</p>
|
||||
<h2 className="font-semibold">{t("diag.title")}</h2>
|
||||
<p className="mt-1 text-sm text-muted">{t("diag.text")}</p>
|
||||
<div className="mt-4 flex flex-wrap gap-2">
|
||||
<Button variant="primary" disabled={!!busy} onClick={() => void run("diag", async () => setChecks((await api.runDiagnostics(serverId)).checks))}>
|
||||
{busy === "diag" && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}
|
||||
Run diagnostics
|
||||
{t("diag.run")}
|
||||
</Button>
|
||||
<Button disabled={!!busy} onClick={() => void run("verify", async () => setFiles(await api.verifyFiles(serverId)))}>
|
||||
Check server files
|
||||
{t("diag.verify")}
|
||||
</Button>
|
||||
<Button variant="ghost" disabled={!!busy} onClick={() => void run("export", async () => setNote(`Saved for bug reports: ${await api.exportDiagnostics(serverId)}`))}>
|
||||
Export diagnostic package
|
||||
<Button variant="ghost" disabled={!!busy} onClick={() => void run("export", async () => setNote(t("diag.saved", { path: await api.exportDiagnostics(serverId) })))}>
|
||||
{t("diag.export")}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{checks && (
|
||||
<div className="mt-4">
|
||||
<p className="font-medium" role="status">{problems === 0 ? "Everything looks good." : `${problems} thing${problems === 1 ? "" : "s"} to look at`}</p>
|
||||
<p className="font-medium" role="status">{problems === 0 ? t("diag.allGood") : tn("diag.problems", problems)}</p>
|
||||
<ul className="mt-2 divide-y divide-line text-sm">
|
||||
{checks.map((c) => {
|
||||
const Icon = ICON[c.level];
|
||||
@@ -58,7 +61,7 @@ export function DiagnosticsCard({ serverId }: { serverId: string }) {
|
||||
<Icon className={`mt-0.5 h-4 w-4 shrink-0 ${TONE[c.level]}`} aria-hidden />
|
||||
<div>
|
||||
<span className="font-medium">{c.title}</span>
|
||||
<span className="sr-only"> — {WORD[c.level]}</span>
|
||||
<span className="sr-only"> — {t(WORD[c.level])}</span>
|
||||
<p className="text-muted">{c.detail}</p>
|
||||
</div>
|
||||
</li>
|
||||
@@ -71,14 +74,14 @@ export function DiagnosticsCard({ serverId }: { serverId: string }) {
|
||||
{files && (
|
||||
<div className="mt-4 border-t border-line pt-3 text-sm">
|
||||
{files.length === 0 ? (
|
||||
<p className="text-ok" role="status">All program files are intact.</p>
|
||||
<p className="text-ok" role="status">{t("diag.filesOk")}</p>
|
||||
) : (
|
||||
<>
|
||||
<p className="text-warn">{files.length} program file(s) differ from what was installed. Your own files are never listed here. "Check for updates" restores missing ones.</p>
|
||||
<p className="text-warn">{t("diag.filesDiffer", { n: files.length })}</p>
|
||||
<ul className="mt-2 max-h-40 overflow-auto">
|
||||
{files.map((f) => (
|
||||
<li key={f.path} className="selectable py-0.5">
|
||||
{f.path} <span className="text-muted">— {f.kind === "missing" ? "missing" : "changed"}</span>
|
||||
{f.path} <span className="text-muted">— {f.kind === "missing" ? t("diag.fileMissing") : t("diag.fileChanged")}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
@@ -87,7 +90,7 @@ export function DiagnosticsCard({ serverId }: { serverId: string }) {
|
||||
</div>
|
||||
)}
|
||||
{note && <p className="mt-3 text-sm text-ok" role="status">{note}</p>}
|
||||
{error && <p className="mt-3 text-sm text-bad" role="alert">{error.human.code === "unknown" ? error.technical : error.human.message}</p>}
|
||||
{error && <p className="mt-3 text-sm text-bad" role="alert">{error.human.code === "unknown" ? error.technical : human(error.human).message}</p>}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user