Add a Swedish interface with a per-person language switch

A small translation system (the English text is its own key, so anything
without a Swedish entry stays English) and a Language switch in the user menu,
saved on the account (users.language) and following the browser when no choice
has been made. Swedish covers the menu, shared parts (search, tables, dialogs,
relative times), the sign-in page and the everyday pages: Dashboard, Alerts,
Servers, Updates, Maintenance, My work, Coming up, To do, Integrations and the
display settings. Server-written messages stay English for now.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-12 21:49:49 +01:00
1 parent e7f23ba13f
commit 645816d5a8
168 files changed
+12142 -1422

No files matched your search

+51 -27
View File
@@ -22,6 +22,7 @@ import { useFormLabels } from "../hooks/useFormLabels";
import ShortcutHelp from "../components/ShortcutHelp";
import Avatar from "../components/Avatar";
import { useBreadcrumbTailValue } from "../utils/breadcrumb";
import { getLanguage, LANGUAGES, setLanguage, t, tn } from "../i18n";
const RAIL_KEY = "hlm-sidebar-rail";
@@ -176,7 +177,7 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
if (!isGroup(entry)) continue;
const leaf = entry.items.find((item) => isCurrent(pathname, item.to));
if (!leaf) continue;
crumbs.push({ label: entry.label }, breadcrumbTail ? { label: leaf.label, to: leaf.to } : { label: leaf.label });
crumbs.push({ label: t(entry.label) }, breadcrumbTail ? { label: t(leaf.label), to: leaf.to } : { label: t(leaf.label) });
if (breadcrumbTail) crumbs.push({ label: breadcrumbTail });
break;
}
@@ -213,21 +214,21 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
badges["/alerts"] = {
text: String(alerts.count),
className: alerts.level === "critical" ? "bg-red text-red-fg" : "bg-yellow text-yellow-fg",
title: `${alerts.count} active alert${alerts.count === 1 ? "" : "s"}`,
title: tn(alerts.count, "{n} active alert", "{n} active alerts"),
};
}
if (myWork && myWork.needsAttention > 0) {
badges["/my-work"] = {
text: String(myWork.needsAttention),
className: "bg-blue text-blue-fg",
title: `${myWork.needsAttention} ${myWork.needsAttention === 1 ? "thing" : "things"} of yours want a look: handed to you, about to run out, or still going`,
title: tn(myWork.needsAttention, "{n} thing of yours wants a look: handed to you, about to run out, or still going", "{n} things of yours want a look: handed to you, about to run out, or still going"),
};
}
if (maintenance.length > 0) {
badges["/maintenance"] = {
text: String(maintenance.length),
className: "bg-blue text-blue-fg",
title: `${maintenance.length} maintenance window${maintenance.length === 1 ? "" : "s"} open`,
title: tn(maintenance.length, "{n} maintenance window open", "{n} maintenance windows open"),
};
}
function toggleTheme() {
@@ -246,7 +247,7 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
mainRef.current?.focus();
}}
>
Skip to content
{t("Skip to content")}
</a>
<div className="visually-hidden" role="status" aria-live="polite" aria-atomic="true">
{announcement}
@@ -258,7 +259,7 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
type="button"
className="navbar-toggler"
onClick={() => setSidebarOpen((open) => !open)}
aria-label="Toggle navigation"
aria-label={t("Toggle navigation")}
>
<IconMenu2 size={20} />
</button>
@@ -288,17 +289,17 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
type="button"
className="rail-toggle d-none d-lg-flex"
aria-expanded={!collapsed}
aria-label={collapsed ? "Widen the sidebar" : "Narrow the sidebar to icons"}
title={collapsed ? "Widen the sidebar ([)" : "Narrow the sidebar to icons ([)"}
aria-label={collapsed ? t("Widen the sidebar") : t("Narrow the sidebar to icons")}
title={collapsed ? t("Widen the sidebar ([)") : t("Narrow the sidebar to icons ([)")}
onClick={() => setCollapsed((c) => !c)}
>
{collapsed ? <IconChevronsRight size={16} /> : <IconChevronsLeft size={16} />}
<span className="rail-toggle-text">Narrow sidebar</span>
<span className="rail-toggle-text">{t("Narrow sidebar")}</span>
</button>
{menuOpen && (
<div className="user-menu-list" role="menu">
<div className="user-menu-density" role="group" aria-label="How tightly pages are packed">
<span className="small opacity-75">Density</span>
<div className="user-menu-density" role="group" aria-label={t("How tightly pages are packed")}>
<span className="small opacity-75">{t("Density")}</span>
<div className="btn-group btn-group-sm w-100">
{DENSITIES.map((d) => (
<button
@@ -311,14 +312,35 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
setDensityState(d.value);
}}
>
{d.label}
{t(d.label)}
</button>
))}
</div>
</div>
<div className="user-menu-density" role="group" aria-label={t("Language")}>
<span className="small opacity-75">{t("Language")}</span>
<div className="btn-group btn-group-sm w-100">
{LANGUAGES.map((l) => (
<button
key={l.code}
type="button"
lang={l.code}
className={`btn ${getLanguage() === l.code ? "active" : ""}`}
aria-pressed={getLanguage() === l.code}
onClick={() => {
// Saved on the account so it follows this person; the screen is drawn again in the new language at once.
setLanguage(l.code);
void api.me.setLanguage(l.code).catch(() => undefined);
}}
>
{l.name}
</button>
))}
</div>
</div>
<button type="button" className="user-menu-item" role="menuitem" onClick={toggleTheme}>
{theme === "dark" ? <IconSun size={16} /> : <IconMoon size={16} />}
{theme === "dark" ? "Light mode" : "Dark mode"}
{theme === "dark" ? t("Light mode") : t("Dark mode")}
</button>
<NavLink
to="/privacy"
@@ -330,7 +352,7 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
}}
>
<IconShieldLock size={16} />
Privacy
{t("Privacy")}
</NavLink>
<NavLink
to="/api-tokens"
@@ -342,7 +364,7 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
}}
>
<IconKey size={16} />
API tokens
{t("API tokens")}
</NavLink>
<NavLink
to="/wall"
@@ -354,11 +376,11 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
}}
>
<IconDeviceDesktop size={16} />
Wall display
{t("Wall display")}
</NavLink>
<a className="user-menu-item" role="menuitem" href="/auth/logout">
<IconLogout size={16} />
Sign out
{t("Sign out")}
</a>
</div>
)}
@@ -389,10 +411,10 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
<div className="alert alert-info d-flex align-items-center gap-2">
<IconPlaneDeparture size={18} />
<div>
{away.away.state === "planned" ? `Away from ${formatDateTime(new Date(away.away.from!))} until ${formatDateTime(new Date(away.away.until))}` : `Away until ${formatDateTime(new Date(away.away.until))}`}
{away.away.state === "planned" ? t("Away from {from} until {until}", { from: formatDateTime(new Date(away.away.from!)), until: formatDateTime(new Date(away.away.until)) }) : t("Away until {until}", { until: formatDateTime(new Date(away.away.until)) })}
{away.away.note ? ` — ${away.away.note}` : ""}.{" "}
{away.away.state === "active" ? `Notifications are held${away.away.criticalThrough ? " (critical alerts still come through)" : ""}${away.held > 0 ? ` — ${away.held} so far` : ""}. ` : ""}
<Link to="/settings/notifications?tab=when">{user.role === "admin" ? "Manage" : "Details"}</Link>
{away.away.state === "active" ? `${t("Notifications are held")}${away.away.criticalThrough ? ` ${t("(critical alerts still come through)")}` : ""}${away.held > 0 ? ` — ${t("{n} so far", { n: away.held })}` : ""}. ` : ""}
<Link to="/settings/notifications?tab=when">{user.role === "admin" ? t("Manage") : t("Details")}</Link>
</div>
</div>
)}
@@ -400,19 +422,21 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
<div className="alert alert-warning d-flex align-items-center gap-2">
<IconTool size={18} />
<div>
Maintenance — alerts silenced for{" "}
{t("Maintenance — alerts silenced for")}{" "}
{maintenance.length <= 3
? maintenance.map((w) => `${w.targetName} (${formatRemaining(w.endsAt)} left)`).join(", ")
: `${maintenance.slice(0, 3).map((w) => w.targetName).join(", ")} and ${maintenance.length - 3} more (the last ends in ${formatRemaining(
maintenance.reduce((latest, w) => (w.endsAt > latest ? w.endsAt : latest), maintenance[0].endsAt),
)})`}
? maintenance.map((w) => t("{name} ({time} left)", { name: w.targetName, time: formatRemaining(w.endsAt) })).join(", ")
: t("{names} and {n} more (the last ends in {time})", {
names: maintenance.slice(0, 3).map((w) => w.targetName).join(", "),
n: maintenance.length - 3,
time: formatRemaining(maintenance.reduce((latest, w) => (w.endsAt > latest ? w.endsAt : latest), maintenance[0].endsAt)),
})}
.{" "}
<Link to="/maintenance">Manage</Link>
<Link to="/maintenance">{t("Manage")}</Link>
</div>
</div>
)}
{crumbs.length > 0 && (
<nav aria-label="breadcrumb" className="mb-2">
<nav aria-label={t("breadcrumb")} className="mb-2">
<ol className="breadcrumb breadcrumb-arrows mb-0">
{crumbs.map((c, i) => (
<li key={i} className={`breadcrumb-item ${i === crumbs.length - 1 ? "active" : ""}`} aria-current={i === crumbs.length - 1 ? "page" : undefined}>