diff --git a/src/i18n/index.tsx b/src/i18n/index.tsx index 3512128..73e0f5e 100644 --- a/src/i18n/index.tsx +++ b/src/i18n/index.tsx @@ -42,10 +42,10 @@ export function lookup(locale: Locale, key: Key, vars?: Vars): string { } /** Plural form: tries `key_` (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({ diff --git a/src/i18n/locales/de.ts b/src/i18n/locales/de.ts index 955823d..677a2c6 100644 --- a/src/i18n/locales/de.ts +++ b/src/i18n/locales/de.ts @@ -198,6 +198,34 @@ const de: Partial> = { "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; diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index c1b7f63..cbfd05b 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -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; diff --git a/src/i18n/locales/es.ts b/src/i18n/locales/es.ts index 4b2a707..7c452b7 100644 --- a/src/i18n/locales/es.ts +++ b/src/i18n/locales/es.ts @@ -198,6 +198,34 @@ const es: Partial> = { "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; diff --git a/src/i18n/locales/fr.ts b/src/i18n/locales/fr.ts index a2c99ff..0941cd6 100644 --- a/src/i18n/locales/fr.ts +++ b/src/i18n/locales/fr.ts @@ -198,6 +198,34 @@ const fr: Partial> = { "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; diff --git a/src/i18n/locales/ru.ts b/src/i18n/locales/ru.ts index b053d9f..cd2810b 100644 --- a/src/i18n/locales/ru.ts +++ b/src/i18n/locales/ru.ts @@ -198,6 +198,34 @@ const ru: Partial> = { "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; diff --git a/src/screens/AboutCard.tsx b/src/screens/AboutCard.tsx index d5184ef..b9d480d 100644 --- a/src/screens/AboutCard.tsx +++ b/src/screens/AboutCard.tsx @@ -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(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 ( -

CoA Server Manager

-

Version {version || "…"}. Updates to the program never change your server.

+

{t("app.name")}

+

{t("about.version", { v: version || "…" })}

{update && ( )} {percent !== null && busy === "install" && {percent}%} diff --git a/src/screens/DiagnosticsCard.tsx b/src/screens/DiagnosticsCard.tsx index 9c42f4a..15b513b 100644 --- a/src/screens/DiagnosticsCard.tsx +++ b/src/screens/DiagnosticsCard.tsx @@ -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(null); const [files, setFiles] = useState<{ path: string; kind: string }[] | null>(null); const [busy, setBusy] = useState(null); @@ -32,24 +35,24 @@ export function DiagnosticsCard({ serverId }: { serverId: string }) { return ( -

Diagnostics

-

Looks for common problems. Nothing is changed.

+

{t("diag.title")}

+

{t("diag.text")}

-
{checks && (
-

{problems === 0 ? "Everything looks good." : `${problems} thing${problems === 1 ? "" : "s"} to look at`}

+

{problems === 0 ? t("diag.allGood") : tn("diag.problems", problems)}

    {checks.map((c) => { const Icon = ICON[c.level]; @@ -58,7 +61,7 @@ export function DiagnosticsCard({ serverId }: { serverId: string }) {
    {c.title} - — {WORD[c.level]} + — {t(WORD[c.level])}

    {c.detail}

    @@ -71,14 +74,14 @@ export function DiagnosticsCard({ serverId }: { serverId: string }) { {files && (
    {files.length === 0 ? ( -

    All program files are intact.

    +

    {t("diag.filesOk")}

    ) : ( <> -

    {files.length} program file(s) differ from what was installed. Your own files are never listed here. "Check for updates" restores missing ones.

    +

    {t("diag.filesDiffer", { n: files.length })}

      {files.map((f) => (
    • - {f.path} — {f.kind === "missing" ? "missing" : "changed"} + {f.path} — {f.kind === "missing" ? t("diag.fileMissing") : t("diag.fileChanged")}
    • ))}
    @@ -87,7 +90,7 @@ export function DiagnosticsCard({ serverId }: { serverId: string }) {
    )} {note &&

    {note}

    } - {error &&

    {error.human.code === "unknown" ? error.technical : error.human.message}

    } + {error &&

    {error.human.code === "unknown" ? error.technical : human(error.human).message}

    } ); }