mirror of
https://github.com/Dvorinka/Dash.git
synced 2026-10-29 00:01:24 +00:00
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>
This commit is contained in:
1 parent
f3143af351
commit
e0ef60eca6
49 files changed
+2131
-426
No files matched your search
@@ -1,13 +1,27 @@
|
||||
import { en, type Key } from "@/i18n/en";
|
||||
import { cs } from "@/i18n/cs";
|
||||
|
||||
export type { Key } from "@/i18n/en";
|
||||
|
||||
// i18n seam: dictionaries are plain objects keyed by dotted names. `t` is a
|
||||
// typed lookup that falls back to the key itself, so a missing translation
|
||||
// renders the key — loud in dev, never a crash. Locales beyond `en` plug in
|
||||
// here later (settings key + lazy import); nothing else changes.
|
||||
const dict: Record<Key, string> = en;
|
||||
export const LOCALES = { en: "English", cs: "Čeština" } as const;
|
||||
export type Locale = keyof typeof LOCALES;
|
||||
|
||||
export function t(key: Key): string {
|
||||
return dict[key] ?? key;
|
||||
// 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;
|
||||
}
|
||||
Reference in new issue
Block a user