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:
1 parent
e7f23ba13f
commit
645816d5a8
168 files changed
+12142
-1422
No files matched your search
@@ -4,6 +4,7 @@ import { IconStar, IconStarFilled } from "@tabler/icons-react";
|
||||
import { isCurrent, isGroup, type NavEntry, type NavGroup, type NavLeaf } from "./nav";
|
||||
import { toggleFavorite, useFavorites } from "../utils/favorites";
|
||||
import { canonicalSearch, describeView, splitView } from "../utils/savedViews";
|
||||
import { t } from "../i18n";
|
||||
|
||||
export interface NavBadge {
|
||||
text: string;
|
||||
@@ -92,9 +93,9 @@ export default function SidebarNav({
|
||||
) : null;
|
||||
};
|
||||
|
||||
const star = (leaf: NavLeaf, path: string = leaf.to, name: string = leaf.label) => {
|
||||
const star = (leaf: NavLeaf, path: string = leaf.to, name: string = t(leaf.label)) => {
|
||||
const on = favorites.includes(path);
|
||||
const label = on ? `Remove ${name} from favourites` : `Add ${name} to favourites`;
|
||||
const label = on ? t("Remove {name} from favourites", { name }) : t("Add {name} to favourites", { name });
|
||||
return (
|
||||
<button type="button" className="fav-star" aria-pressed={on} aria-label={label} title={label} onClick={() => void toggleFavorite(path)}>
|
||||
{on ? <IconStarFilled size={16} /> : <IconStar size={16} />}
|
||||
@@ -104,14 +105,14 @@ export default function SidebarNav({
|
||||
|
||||
const viewRow = (leaf: NavLeaf, path: string, search: string) => {
|
||||
const words = describeView(search);
|
||||
const name = `${leaf.label}: ${words}`;
|
||||
const name = `${t(leaf.label)}: ${words}`;
|
||||
const here = location.pathname === leaf.to && canonicalSearch(location.search) === search;
|
||||
return (
|
||||
<li className="nav-item nav-row" key={`fav-${path}`}>
|
||||
<NavLink to={path} className={() => `nav-link ${here ? "active" : ""}`} title={rail ? name : undefined} aria-current={here ? "page" : undefined} onClick={onNavigate}>
|
||||
<span className="nav-link-icon d-md-none d-lg-inline-block">{leaf.icon}</span>
|
||||
<span className="nav-link-title">
|
||||
{leaf.label} <span className="nav-view">{words}</span>
|
||||
{t(leaf.label)} <span className="nav-view">{words}</span>
|
||||
</span>
|
||||
</NavLink>
|
||||
{star(leaf, path, name)}
|
||||
@@ -121,9 +122,9 @@ export default function SidebarNav({
|
||||
|
||||
const leafRow = (leaf: NavLeaf, key: string) => (
|
||||
<li className="nav-item nav-row" key={key}>
|
||||
<NavLink to={leaf.to} end={leaf.to === "/"} className="nav-link" title={rail ? leaf.label : undefined} onClick={onNavigate}>
|
||||
<NavLink to={leaf.to} end={leaf.to === "/"} className="nav-link" title={rail ? t(leaf.label) : undefined} onClick={onNavigate}>
|
||||
<span className="nav-link-icon d-md-none d-lg-inline-block">{leaf.icon}</span>
|
||||
<span className="nav-link-title">{leaf.label}</span>
|
||||
<span className="nav-link-title">{t(leaf.label)}</span>
|
||||
{badgeOf(leaf.to)}
|
||||
</NavLink>
|
||||
{star(leaf)}
|
||||
@@ -136,7 +137,7 @@ export default function SidebarNav({
|
||||
<span className="menu-item-icon" aria-hidden="true">
|
||||
{leaf.icon}
|
||||
</span>
|
||||
{leaf.label}
|
||||
{t(leaf.label)}
|
||||
{badgeOf(leaf.to)}
|
||||
</NavLink>
|
||||
{star(leaf)}
|
||||
@@ -144,7 +145,7 @@ export default function SidebarNav({
|
||||
);
|
||||
|
||||
return (
|
||||
<nav aria-label="Main menu">
|
||||
<nav aria-label={t("Main menu")}>
|
||||
<ul className="navbar-nav pt-lg-3">
|
||||
{pinned.length > 0 && (
|
||||
<li className="nav-item nav-favourites">
|
||||
@@ -171,7 +172,7 @@ export default function SidebarNav({
|
||||
type="button"
|
||||
className={`nav-link dropdown-toggle w-100 border-0 bg-transparent text-start ${(rail ? flyOpen : open) ? "show" : ""} ${holdsCurrent ? "active" : ""}`}
|
||||
aria-expanded={rail ? flyOpen : open}
|
||||
title={rail ? entry.label : undefined}
|
||||
title={rail ? t(entry.label) : undefined}
|
||||
onClick={(e) => {
|
||||
if (!rail) return onToggleGroup(entry.id);
|
||||
if (flyOpen) return setFlyout(null);
|
||||
@@ -181,7 +182,7 @@ export default function SidebarNav({
|
||||
}}
|
||||
>
|
||||
<span className="nav-link-icon d-md-none d-lg-inline-block">{entry.icon}</span>
|
||||
<span className="nav-link-title">{entry.label}</span>
|
||||
<span className="nav-link-title">{t(entry.label)}</span>
|
||||
{/* A closed group still says that something inside it needs a look. */}
|
||||
{showSummary && (
|
||||
<span className={`badge ms-auto me-4 ${worst.className}`} title={inside.map((b) => b.title).join(", ")}>
|
||||
@@ -197,8 +198,8 @@ export default function SidebarNav({
|
||||
</ul>
|
||||
|
||||
{rail && flyout && (
|
||||
<div ref={flyoutRef} className="rail-flyout" role="group" aria-label={flyout.group.label} style={{ top: flyout.top, left: flyout.left, maxHeight: `calc(100vh - ${flyout.top}px - 0.75rem)` }}>
|
||||
<div className="rail-flyout-title">{flyout.group.label}</div>
|
||||
<div ref={flyoutRef} className="rail-flyout" role="group" aria-label={t(flyout.group.label)} style={{ top: flyout.top, left: flyout.left, maxHeight: `calc(100vh - ${flyout.top}px - 0.75rem)` }}>
|
||||
<div className="rail-flyout-title">{t(flyout.group.label)}</div>
|
||||
{flyout.group.items.map(subRow)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user