Files
Dash/apps/frontend/src/i18n/index.ts
T
Tomas DvorakandDevin e0ef60eca6 feat(ui): phase 5 — graphs, widgets, theming, PWA, boards, i18n
P5a: 24h uptime bar strip + latency chart on monitor detail, iframe
embed widget, generic JSON-path widget, accent/wallpaper/custom CSS
settings, PWA manifest + service worker, demo GIF.

P5b: transport picker + per-transport fields + test button in
settings; per-monitor alert-rule fields in dialogs.

P5c: container cpu/mem columns, SMART/ZFS/GPU sections on system
detail, subdomains section on domain detail.

P5d: login/setup page + auth middleware client handling, board
switcher + /b/:slug routes, full string extraction to typed t() keys
with {param} interpolation, complete cs locale, language select.

Authored By: TDvorak <[email protected]>

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-22 12:49:51 +02:00

28 lines
1010 B
TypeScript

import { en, type Key } from "@/i18n/en";
import { cs } from "@/i18n/cs";
export type { Key } from "@/i18n/en";
export const LOCALES = { en: "English", cs: "Čeština" } as const;
export type Locale = keyof typeof LOCALES;
// i18n seam: dictionaries are plain objects keyed by dotted names. `t` is a
// typed lookup that falls back to English, then to the key itself — a missing
// translation is loud in dev, never a crash. The store calls setLocale when
// the `locale` setting loads/changes; components re-render on prefs updates.
const dicts: Record<Locale, Partial<Record<Key, string>>> = { en, cs };
let active: Locale = "en";
export function setLocale(l: string) {
active = l === "cs" ? "cs" : "en";
document.documentElement.lang = active;
}
export function t(key: Key, params?: Record<string, string | number>): string {
let s: string = dicts[active][key] ?? en[key] ?? key;
if (params) {
for (const [k, v] of Object.entries(params)) s = s.replaceAll(`{${k}}`, String(v));
}
return s;
}