Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

feat(i18n): translate the shared shell; seed the common vocabulary

Juan Denis2103bb87bdb8
diff --git a/frontend/scripts/I18N_LITERAL_CEILING b/frontend/scripts/I18N_LITERAL_CEILING
index 432080b5..f4f7d043 100644
--- a/frontend/scripts/I18N_LITERAL_CEILING
+++ b/frontend/scripts/I18N_LITERAL_CEILING
@@ -1 +1 @@
-8225
+8132
diff --git a/frontend/scripts/check-i18n-literals.mjs b/frontend/scripts/check-i18n-literals.mjs
index 5fb4bd88..32b61a97 100644
--- a/frontend/scripts/check-i18n-literals.mjs
+++ b/frontend/scripts/check-i18n-literals.mjs
@@ -77,6 +77,9 @@ const SKIP_FILE = /\.(test|spec|stories)\.[jt]sx?$/;
// door's own fallback strings.
const SKIP_PATH = /^(i18n\/|data\/bundledThemes)/;
+// A dotted, lowercase-namespaced path: `nav.dashboard`, `common.actions.save`.
+const TRANSLATION_KEY = /^[a-z][a-zA-Z0-9]*(\.[a-zA-Z0-9_]+)+$/;
+
/**
* Does this literal read as prose a user would notice?
*
@@ -191,6 +194,10 @@ function censusFile(path, rel) {
}
const hits = [];
+ // Properties exempted because the object also declares a translation key
+ // for them: `{ labelKey: 'nav.apps', label: 'Applications' }`. The label is
+ // the English default for that key, resolved at render -- not stray copy.
+ const keyed = new WeakSet();
const record = (node, kind, value) => {
const text = String(value).trim().replace(/\s+/g, ' ');
if (!isCopy(text)) return;
@@ -251,8 +258,26 @@ function censusFile(path, rel) {
break;
}
+ // Declarative key pairs, marked before their properties are seen.
+ case 'ObjectExpression': {
+ const named = new Map();
+ for (const property of node.properties) {
+ if (property.type !== 'Property' || property.computed) continue;
+ named.set(property.key?.name || property.key?.value, property);
+ }
+ for (const [name, property] of named) {
+ if (!name || !name.endsWith('Key')) continue;
+ if (property.value?.type !== 'Literal') continue;
+ if (!TRANSLATION_KEY.test(String(property.value.value))) continue;
+ const sibling = named.get(name.slice(0, -3));
+ if (sibling) keyed.add(sibling);
+ }
+ break;
+ }
+
// 4. Copy keys in data objects.
case 'Property': {
+ if (keyed.has(node)) return;
const key = propertyKey(node);
if (key && COPY_KEYS.has(key) && node.value?.type === 'Literal'
&& typeof node.value.value === 'string') {
diff --git a/frontend/scripts/extract-i18n.mjs b/frontend/scripts/extract-i18n.mjs
index 106cc2d3..ea7cdbde 100644
--- a/frontend/scripts/extract-i18n.mjs
+++ b/frontend/scripts/extract-i18n.mjs
@@ -55,6 +55,25 @@ function isTranslationCall(node) {
&& node.callee.name === 't';
}
+/**
+ * Is SOME default declared? For a computed key the default is computed too
+ * (`t(item.labelKey, { defaultValue: item.label })`), so it cannot be
+ * extracted — but its presence is still what stops a missing bundle rendering
+ * the raw key path to a user, and that is what this gate is for.
+ */
+function hasDefault(node) {
+ const [, second, third] = node.arguments;
+ if (second?.type === 'Literal' && typeof second.value === 'string') return true;
+ for (const candidate of [second, third]) {
+ if (candidate?.type !== 'ObjectExpression') continue;
+ for (const property of candidate.properties) {
+ if (property.type !== 'Property' || property.computed) continue;
+ if ((property.key.name || property.key.value) === 'defaultValue') return true;
+ }
+ }
+ return false;
+}
+
/** The English default declared at a call site, or null. */
function defaultValueOf(node) {
const [, second, third] = node.arguments;
@@ -72,17 +91,82 @@ function defaultValueOf(node) {
return null;
}
-function visit(node, onCall) {
+// Declarative keys in data files.
+//
+// A label sitting in a data table (sidebarItems.js, tab tables, column defs)
+// is still copy, but it cannot be a `t()` call: resolving at module load would
+// translate it once, at import, and never again on a locale switch. So the
+// data declares the pair
+//
+// { labelKey: 'nav.dashboard', label: 'Dashboard' }
+//
+// and the renderer resolves `t(item.labelKey, item.label)` at render time.
+// This collects the pair at its declaration site, the only place both halves
+// are literal.
+// A dotted, lowercase-namespaced path: `nav.dashboard`, `common.actions.save`.
+const TRANSLATION_KEY = /^[a-z][a-zA-Z0-9]*(\.[a-zA-Z0-9_]+)+$/;
+
+function declarativePairs(node) {
+ if (node.type !== 'ObjectExpression') return null;
+ const literals = new Map();
+ for (const property of node.properties) {
+ if (property.type !== 'Property' || property.computed) continue;
+ const name = property.key.name || property.key.value;
+ if (property.value?.type === 'Literal' && typeof property.value.value === 'string') {
+ literals.set(name, property.value.value);
+ }
+ }
+ const pairs = [];
+ for (const [name, value] of literals) {
+ if (!name.endsWith('Key')) continue;
+ const sibling = name.slice(0, -3);
+ // The value must LOOK like a translation key. `Key` already means
+ // "identifier" in several places -- `archKey: 'amd64'` next to
+ // `arch: 'x64 (amd64)'` is a CPU architecture, not copy, and a looser
+ // rule silently pulled it into en.json.
+ if (!TRANSLATION_KEY.test(value)) continue;
+ if (literals.has(sibling)) pairs.push({ key: value, value: literals.get(sibling) });
+ }
+ return pairs.length ? pairs : null;
+}
+
+// <Trans i18nKey="..." defaults="Type <0>{{value}}</0> to confirm:" />
+//
+// A sentence with an element inside it cannot be a plain `t()` call, and it
+// must not be split into prefix/suffix keys either: word order differs by
+// language, and a split sentence cannot be reordered by a translator.
+function transPair(node) {
+ if (node.type !== 'JSXElement') return null;
+ const name = node.openingElement?.name;
+ if (name?.type !== 'JSXIdentifier' || name.name !== 'Trans') return null;
+
+ const literals = new Map();
+ for (const attribute of node.openingElement.attributes) {
+ if (attribute.type !== 'JSXAttribute') continue;
+ if (attribute.value?.type === 'Literal' && typeof attribute.value.value === 'string') {
+ literals.set(attribute.name.name, attribute.value.value);
+ }
+ }
+ const key = literals.get('i18nKey');
+ const value = literals.get('defaults');
+ return key && value ? { key, value } : null;
+}
+
+function visit(node, onCall, onPair) {
if (!node || typeof node !== 'object') return;
if (Array.isArray(node)) {
- for (const child of node) visit(child, onCall);
+ for (const child of node) visit(child, onCall, onPair);
return;
}
if (!node.type) return;
if (isTranslationCall(node)) onCall(node);
+ const pairs = declarativePairs(node);
+ if (pairs) for (const pair of pairs) onPair(pair, node);
+ const trans = transPair(node);
+ if (trans) onPair(trans, node);
for (const key of Object.keys(node)) {
if (key === 'type' || key === 'loc' || key === 'range') continue;
- visit(node[key], onCall);
+ visit(node[key], onCall, onPair);
}
}
@@ -105,23 +189,7 @@ export function collect() {
continue;
}
- visit(ast, (node) => {
- const first = node.arguments[0];
- const site = `${rel}:${node.loc.start.line}`;
-
- if (first?.type !== 'Literal' || typeof first.value !== 'string') {
- // A computed key cannot be extracted, so its English can only
- // live in en.json by hand -- which the generated file forbids.
- problems.push(`${site}: t() called with a non-literal key`);
- return;
- }
- const key = first.value;
- const value = defaultValueOf(node);
- if (value === null) {
- problems.push(`${site}: t('${key}') has no inline English default`);
- return;
- }
-
+ const record = (key, value, site) => {
const existing = entries.get(key);
if (existing && existing.value !== value) {
problems.push(
@@ -136,7 +204,33 @@ export function collect() {
return;
}
entries.set(key, { value, sites: [site] });
- });
+ };
+
+ visit(
+ ast,
+ (node) => {
+ const first = node.arguments[0];
+ const site = `${rel}:${node.loc.start.line}`;
+ const value = defaultValueOf(node);
+
+ if (first?.type !== 'Literal' || typeof first.value !== 'string') {
+ // A computed key is legitimate when the pair was declared
+ // in data (see declarativePair) and this site only resolves
+ // it -- but only if a default rides along, or a missing
+ // bundle renders the raw key path to a user.
+ if (!hasDefault(node)) {
+ problems.push(`${site}: t() has a computed key and no defaultValue`);
+ }
+ return;
+ }
+ if (value === null) {
+ problems.push(`${site}: t('${first.value}') has no inline English default`);
+ return;
+ }
+ record(first.value, value, site);
+ },
+ (pair, node) => record(pair.key, pair.value, `${rel}:${node.loc.start.line}`),
+ );
}
return { entries, problems };
diff --git a/frontend/src/components/AppLoader.jsx b/frontend/src/components/AppLoader.jsx
index 7f823401..810b34e6 100644
--- a/frontend/src/components/AppLoader.jsx
+++ b/frontend/src/components/AppLoader.jsx
@@ -1,3 +1,4 @@
+import { t } from '../i18n';
/**
* Full-screen initial loader shown while auth/setup state is resolved.
*
@@ -8,7 +9,7 @@
*/
export function AppLoader() {
return (
- <div className="app-loader" role="status" aria-live="polite" aria-label="Loading ServerKit">
+ <div className="app-loader" role="status" aria-live="polite" aria-label={t('common.state.loadingApp', 'Loading ServerKit')}>
<div className="app-loader__logo">
<svg
className="app-loader__glyph"
@@ -30,7 +31,7 @@ export function AppLoader() {
<div className="app-loader__bar" aria-hidden="true">
<span className="app-loader__bar-fill" />
</div>
- <span className="app-loader__label">Loading ServerKit</span>
+ <span className="app-loader__label">{t('common.state.loadingApp', 'Loading ServerKit')}</span>
</div>
);
}
diff --git a/frontend/src/components/CommandPalette.jsx b/frontend/src/components/CommandPalette.jsx
index fdd36ec4..b976226a 100644
--- a/frontend/src/components/CommandPalette.jsx
+++ b/frontend/src/components/CommandPalette.jsx
@@ -1,5 +1,7 @@
import { useState, useEffect, useCallback, useMemo } from 'react';
import { useNavigate } from 'react-router-dom';
+import { useTranslation } from 'react-i18next';
+import { translateLabel } from '../i18n/labels';
import {
History, SlidersHorizontal, LayoutGrid, Zap, Server, Globe,
Database, Boxes, Puzzle, BookOpen, KeyRound, Clock, ExternalLink, Star,
@@ -67,13 +69,13 @@ const TYPE_LABEL = {
// Docs entries derived from the single docsLinks map (plan 40). Hidden under
// White Label since they point at the public serverkit.ai docs.
const DOCS_ENTRIES = [
- { key: 'deploySources', label: 'Docs: Deploy sources', keywords: 'deploy source repo git' },
- { key: 'manifest', label: 'Docs: serverkit.yaml manifest', keywords: 'manifest yaml declarative' },
- { key: 'extensions', label: 'Docs: Extensions', keywords: 'extension plugin' },
- { key: 'extensionsInstalling', label: 'Docs: Installing extensions', keywords: 'install extension' },
- { key: 'extensionsBuilding', label: 'Docs: Building extensions', keywords: 'build extension develop sdk' },
- { key: 'extensionsPublishing', label: 'Docs: Publishing extensions', keywords: 'publish extension registry' },
- { key: 'extensionsSecurity', label: 'Docs: Extension security', keywords: 'extension security permissions' },
+ { key: 'deploySources', labelKey: 'palette.docs.deploySources', label: 'Docs: Deploy sources', keywords: 'deploy source repo git' },
+ { key: 'manifest', labelKey: 'palette.docs.manifest', label: 'Docs: serverkit.yaml manifest', keywords: 'manifest yaml declarative' },
+ { key: 'extensions', labelKey: 'palette.docs.extensions', label: 'Docs: Extensions', keywords: 'extension plugin' },
+ { key: 'extensionsInstalling', labelKey: 'palette.docs.extensionsInstalling', label: 'Docs: Installing extensions', keywords: 'install extension' },
+ { key: 'extensionsBuilding', labelKey: 'palette.docs.extensionsBuilding', label: 'Docs: Building extensions', keywords: 'build extension develop sdk' },
+ { key: 'extensionsPublishing', labelKey: 'palette.docs.extensionsPublishing', label: 'Docs: Publishing extensions', keywords: 'publish extension registry' },
+ { key: 'extensionsSecurity', labelKey: 'palette.docs.extensionsSecurity', label: 'Docs: Extension security', keywords: 'extension security permissions' },
];
const PER_GROUP_CAP = 6;
@@ -94,6 +96,7 @@ function capGroups(items, perGroup = PER_GROUP_CAP, overall = OVERALL_CAP) {
}
const CommandPalette = ({ open, onClose }) => {
+ const { t } = useTranslation();
const [query, setQuery] = useState('');
const [entityItems, setEntityItems] = useState([]);
const navigate = useNavigate();
@@ -168,13 +171,13 @@ const CommandPalette = ({ open, onClose }) => {
.filter((d) => DOCS_LINKS[d.key])
.map((d) => ({
id: `docs:${d.key}`,
- label: d.label,
+ label: translateLabel(t, d),
keywords: d.keywords || '',
path: DOCS_LINKS[d.key],
category: 'Docs',
external: true,
}));
- }, [whiteLabel]);
+ }, [whiteLabel, t]);
// --- Favorites + visited entities (localStorage, refreshed per open) -----
const favoriteItems = useMemo(
@@ -327,7 +330,7 @@ const CommandPalette = ({ open, onClose }) => {
<CommandDialog
open={open}
shouldFilter={false}
- label="Command palette"
+ label={t('palette.label', 'Command palette')}
onOpenChange={(isOpen) => { if (!isOpen) onClose(); }}
>
<CommandInput
@@ -336,7 +339,7 @@ const CommandPalette = ({ open, onClose }) => {
onValueChange={setQuery}
/>
<CommandList>
- <CommandEmpty>No results found</CommandEmpty>
+ <CommandEmpty>{t('common.state.noResults', 'No results found')}</CommandEmpty>
{grouped.map(([category, items]) => {
const Icon = CATEGORY_ICONS[category] || LayoutGrid;
return (
diff --git a/frontend/src/components/ConfirmDialog.jsx b/frontend/src/components/ConfirmDialog.jsx
index 8956cc83..e149688b 100644
--- a/frontend/src/components/ConfirmDialog.jsx
+++ b/frontend/src/components/ConfirmDialog.jsx
@@ -1,4 +1,5 @@
import { useState, useEffect } from 'react';
+import { Trans } from 'react-i18next';
import { AlertTriangle, Info, AlertCircle } from 'lucide-react';
import {
AlertDialog,
@@ -53,7 +54,15 @@ export function ConfirmDialog({
{requireConfirmation && (
<div className="sk-confirm__confirm-field">
<Label>
- Type <strong className="text-foreground">{requireConfirmation}</strong> to confirm:
+ {/* One key, not a prefix/suffix pair: word order around the
+ typed value differs by language, and split sentences cannot
+ be reordered by a translator. */}
+ <Trans
+ i18nKey="common.confirm.typeToConfirm"
+ defaults="Type <0>{{value}}</0> to confirm:"
+ values={{ value: requireConfirmation }}
+ components={[<strong key="value" className="text-foreground" />]}
+ />
</Label>
<Input
value={inputValue}
diff --git a/frontend/src/components/EmptyState.jsx b/frontend/src/components/EmptyState.jsx
index 7653e46e..a03f9aa1 100644
--- a/frontend/src/components/EmptyState.jsx
+++ b/frontend/src/components/EmptyState.jsx
@@ -1,5 +1,6 @@
import { Inbox } from 'lucide-react';
import { PageSkeleton } from './PageSkeleton';
+import { t } from '../i18n';
/**
* `loadingVariant` names the shape of the page that is loading — see
@@ -24,7 +25,7 @@ export default function EmptyState({
className={`empty-state empty-state--${size} empty-state--loading`}
role="status"
aria-busy="true"
- aria-label={title || 'Loading'}
+ aria-label={title || t('common.state.loading', 'Loading')}
>
<PageSkeleton variant={loadingVariant} rows={loadingRows} />
</div>
diff --git a/frontend/src/components/ErrorBoundary.jsx b/frontend/src/components/ErrorBoundary.jsx
index f09379fb..3d15e594 100644
--- a/frontend/src/components/ErrorBoundary.jsx
+++ b/frontend/src/components/ErrorBoundary.jsx
@@ -1,6 +1,7 @@
import { Component } from 'react';
import { AlertTriangle, RefreshCw } from 'lucide-react';
import api from '../services/api';
+import { t } from '../i18n';
// Class-based Error Boundary for catching React errors
export class ErrorBoundary extends Component {
@@ -45,13 +46,13 @@ export class ErrorBoundary extends Component {
<div className="error-boundary-icon">
<AlertTriangle size={32} />
</div>
- <h3>Something went wrong</h3>
+ <h3>{t('common.error.title', 'Something went wrong')}</h3>
<p className="error-boundary-message">
- {this.state.error?.message || 'An unexpected error occurred'}
+ {this.state.error?.message || t('common.error.unexpected', 'An unexpected error occurred')}
</p>
<button type="button" className="btn btn-primary" onClick={this.handleRetry}>
<RefreshCw size={14} />
- Try Again
+ {t('common.actions.tryAgain', 'Try again')}
</button>
</div>
);
@@ -63,13 +64,14 @@ export class ErrorBoundary extends Component {
// Functional component for displaying API/fetch errors
export function ErrorState({
- title = 'Failed to load',
+ title = t('common.error.failedToLoad', 'Failed to load'),
message,
error,
onRetry,
compact = false
}) {
- const errorMessage = message || error?.message || 'An error occurred while loading data';
+ const errorMessage = message || error?.message
+ || t('common.error.loadingData', 'An error occurred while loading data');
if (compact) {
return (
@@ -78,7 +80,7 @@ export function ErrorState({
<span>{errorMessage}</span>
{onRetry && (
<button type="button" className="btn btn-ghost btn-sm" onClick={onRetry}>
- <RefreshCw size={14} /> Retry
+ <RefreshCw size={14} /> {t('common.actions.retry', 'Retry')}
</button>
)}
</div>
@@ -95,7 +97,7 @@ export function ErrorState({
{onRetry && (
<button type="button" className="btn btn-primary" onClick={onRetry}>
<RefreshCw size={14} />
- Try Again
+ {t('common.actions.tryAgain', 'Try again')}
</button>
)}
</div>
diff --git a/frontend/src/components/ErrorState.jsx b/frontend/src/components/ErrorState.jsx
index bca450f7..a17ab321 100644
--- a/frontend/src/components/ErrorState.jsx
+++ b/frontend/src/components/ErrorState.jsx
@@ -1,5 +1,6 @@
import { AlertTriangle, RefreshCw } from 'lucide-react';
import { Button } from '@/components/ui/button';
+import { t } from '@/i18n';
/**
* Consistent error state for pages and panels. Shows an icon, title, message,
@@ -21,7 +22,7 @@ export function ErrorState({ title = 'Something went wrong', message, onRetry, c
{message && <p className="sk-error-state__message">{message}</p>}
{onRetry && (
<Button variant="outline" size="sm" onClick={onRetry}>
- <RefreshCw size={14} /> Try again
+ <RefreshCw size={14} /> {t('common.actions.tryAgain', 'Try again')}
</Button>
)}
</div>
diff --git a/frontend/src/components/MobileTopBar.jsx b/frontend/src/components/MobileTopBar.jsx
index 3332644c..86e14d34 100644
--- a/frontend/src/components/MobileTopBar.jsx
+++ b/frontend/src/components/MobileTopBar.jsx
@@ -1,4 +1,5 @@
import { Menu, X } from 'lucide-react';
+import { t } from '../i18n';
import { useTheme } from '../contexts/ThemeContext';
import ServerKitLogo from './ServerKitLogo';
import NotificationBell from './NotificationBell';
@@ -18,7 +19,9 @@ const MobileTopBar = ({ navOpen, onToggle }) => {
<button
type="button"
className="mobile-topbar__toggle"
- aria-label={navOpen ? 'Close navigation menu' : 'Open navigation menu'}
+ aria-label={navOpen
+ ? t('nav.closeMenu', 'Close navigation menu')
+ : t('nav.openMenu', 'Open navigation menu')}
aria-expanded={navOpen}
aria-controls="primary-navigation"
onClick={onToggle}
diff --git a/frontend/src/components/NotificationBell.jsx b/frontend/src/components/NotificationBell.jsx
index d58423a6..489ae45c 100644
--- a/frontend/src/components/NotificationBell.jsx
+++ b/frontend/src/components/NotificationBell.jsx
@@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom';
import { Bell, Check, X } from 'lucide-react';
import { useNotifications } from '../contexts/NotificationsContext';
import { timeAgo } from '../utils/time';
+import { useTranslation } from 'react-i18next';
// Severity → dot color, mirroring the email/brand palette.
const SEVERITY_DOT = {
@@ -14,6 +15,7 @@ const SEVERITY_DOT = {
};
export default function NotificationBell() {
+ const { t } = useTranslation();
const ctx = useNotifications();
const [open, setOpen] = useState(false);
const ref = useRef(null);
@@ -67,7 +69,9 @@ export default function NotificationBell() {
type="button"
className="sk-notif__bell"
onClick={toggle}
- aria-label={unreadCount ? `Notifications, ${unreadCount} unread` : 'Notifications'}
+ aria-label={unreadCount
+ ? t('notifications.bellUnread', 'Notifications, {{count}} unread', { count: unreadCount })
+ : t('notifications.bell', 'Notifications')}
aria-haspopup="true"
aria-expanded={open}
>
@@ -76,19 +80,19 @@ export default function NotificationBell() {
</button>
{open && (
- <div className="sk-notif__panel" role="menu" aria-label="Notifications">
+ <div className="sk-notif__panel" role="menu" aria-label={t('notifications.bell', 'Notifications')}>
<div className="sk-notif__head">
- <span className="sk-notif__heading">Notifications</span>
+ <span className="sk-notif__heading">{t('notifications.heading', 'Notifications')}</span>
{unreadCount > 0 && (
<button type="button" className="sk-notif__markall" onClick={markAllRead}>
- <Check size={13} aria-hidden="true" /> Mark all read
+ <Check size={13} aria-hidden="true" /> {t('notifications.markAllRead', 'Mark all read')}
</button>
)}
</div>
<div className="sk-notif__list">
{items.length === 0 ? (
- <div className="sk-notif__empty">You&rsquo;re all caught up.</div>
+ <div className="sk-notif__empty">{t('notifications.empty', 'You’re all caught up.')}</div>
) : (
items.map((item) => (
item.kind === 'notice' ? (
@@ -115,7 +119,7 @@ export default function NotificationBell() {
type="button"
className="sk-notif__dismiss"
onClick={() => dismissNotice && dismissNotice(item.notice_id)}
- aria-label={`Dismiss ${item.title}`}
+ aria-label={t('notifications.dismissItem', 'Dismiss {{title}}', { title: item.title })}
>
<X size={14} aria-hidden="true" />
</button>
@@ -151,7 +155,7 @@ export default function NotificationBell() {
className="sk-notif__seeall"
onClick={() => { setOpen(false); navigate('/notifications'); }}
>
- See all notifications
+ {t('notifications.seeAll', 'See all notifications')}
</button>
</div>
)}
diff --git a/frontend/src/components/Sidebar.jsx b/frontend/src/components/Sidebar.jsx
index 35a24978..1f584c04 100644
--- a/frontend/src/components/Sidebar.jsx
+++ b/frontend/src/components/Sidebar.jsx
@@ -7,7 +7,9 @@ import { Star, Settings, LogOut, Sun, Moon, Monitor, ChevronRight, ChevronDown,
import { api } from '../services/api';
import WorkspaceSwitcher from './WorkspaceSwitcher';
import NotificationBell from './NotificationBell';
-import { SIDEBAR_CATEGORIES, CATEGORY_LABELS, SIDEBAR_PRESETS, getHiddenItemIds, getVisibleItems, applyWorkspaceNavPermissions } from './sidebarItems';
+import { SIDEBAR_CATEGORIES, CATEGORY_LABELS, CATEGORY_LABEL_KEYS, SIDEBAR_PRESETS, getHiddenItemIds, getVisibleItems, applyWorkspaceNavPermissions } from './sidebarItems';
+import { useTranslation } from 'react-i18next';
+import useLabel from '../i18n/labels';
import { useContributions } from '../plugins/contributions';
import { sanitizeSvgInner } from '../utils/sanitizeSvg';
import useModules from '../hooks/useModules';
@@ -16,6 +18,8 @@ import QuickCreate from './QuickCreate';
import { useWorkspace } from '../contexts/WorkspaceContext';
const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {} }) => {
+ const { t } = useTranslation();
+ const label = useLabel();
const { user, logout, updateUser, hasPermission } = useAuth();
const { theme, resolvedTheme, setTheme, whiteLabel } = useTheme();
const { layout, setLayout } = useLayout();
@@ -268,14 +272,16 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
aria-hidden="true" focusable="false"
dangerouslySetInnerHTML={{ __html: sanitizeSvgInner(item.icon) }}
/>
- {item.label}
+ {label(item)}
</NavLink>
{visibleSubs.length > 0 && (
<button
type="button"
className={`nav-expand-btn ${isExpanded ? 'expanded' : ''}`}
aria-expanded={isExpanded}
- aria-label={`${isExpanded ? 'Collapse' : 'Expand'} ${item.label}`}
+ aria-label={isExpanded
+ ? t('nav.collapseGroup', 'Collapse {{group}}', { group: label(item) })
+ : t('nav.expandGroup', 'Expand {{group}}', { group: label(item) })}
onClick={(e) => { e.stopPropagation(); toggleExpand(item.id); }}
>
<ChevronRight size={14} aria-hidden="true" />
@@ -292,7 +298,7 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
aria-hidden="true" focusable="false"
dangerouslySetInnerHTML={{ __html: sanitizeSvgInner(sub.icon) }}
/>
- {sub.label}
+ {label(sub)}
</NavLink>
))}
</React.Fragment>
@@ -304,13 +310,13 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
ref={sidebarRef}
id="primary-navigation"
className={`sidebar${mobileOpen ? ' sidebar--mobile-open' : ''}`}
- aria-label="Main navigation"
+ aria-label={t('nav.mainNavigation', 'Main navigation')}
>
{isMobile && (
<button
type="button"
className="sidebar__close"
- aria-label="Close navigation menu"
+ aria-label={t('nav.closeMenu', 'Close navigation menu')}
onClick={onMobileClose}
>
<X size={20} aria-hidden="true" />
@@ -321,7 +327,7 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
{whiteLabel.mode === 'image_full' ? (
<div className="brand-custom-banner">
{whiteLabel.logoData ? (
- <img src={whiteLabel.logoData} alt={whiteLabel.brandName || 'Brand'} />
+ <img src={whiteLabel.logoData} alt={whiteLabel.brandName || t('nav.brand', 'Brand')} />
) : (
<Layers size={32} />
)}
@@ -334,7 +340,7 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
<>
<div className="brand-custom-logo">
{whiteLabel.logoData ? (
- <img src={whiteLabel.logoData} alt={whiteLabel.brandName || 'Brand'} />
+ <img src={whiteLabel.logoData} alt={whiteLabel.brandName || t('nav.brand', 'Brand')} />
) : (
<Layers size={20} />
)}
@@ -356,8 +362,8 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
target="_blank"
rel="noopener noreferrer"
className="brand-star"
- aria-label="Star ServerKit on GitHub"
- title="Star on GitHub"
+ aria-label={t('nav.starOnGithubLong', 'Star ServerKit on GitHub')}
+ title={t('nav.starOnGithub', 'Star on GitHub')}
>
<Star size={14} aria-hidden="true" />
</a>
@@ -377,7 +383,9 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
return (
<React.Fragment key={cat}>
<div className={`nav-category${isFirst ? ' nav-category--create' : ''}`}>
- {isFirst ? <span>{CATEGORY_LABELS[cat]}</span> : CATEGORY_LABELS[cat]}
+ {isFirst
+ ? <span>{t(CATEGORY_LABEL_KEYS[cat], { defaultValue: CATEGORY_LABELS[cat] })}</span>
+ : t(CATEGORY_LABEL_KEYS[cat], { defaultValue: CATEGORY_LABELS[cat] })}
{isFirst && <QuickCreate variant="sidebar" />}
</div>
<nav className="nav">
@@ -390,7 +398,7 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
{devMode && (
<>
- <div className="nav-category nav-category--dev">Dev Tools</div>
+ <div className="nav-category nav-category--dev">{t('nav.devTools', 'Dev Tools')}</div>
<nav className="nav">
{import.meta.env.DEV && (
<>
@@ -403,7 +411,7 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
<line x1="8" y1="2" x2="8" y2="18"/>
<line x1="16" y1="6" x2="16" y2="22"/>
</svg>
- App Map
+ {t('nav.appMap', 'App Map')}
</NavLink>
<NavLink
to="/documentation"
@@ -413,7 +421,7 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
<path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"/>
<path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"/>
</svg>
- Documentation
+ {t('nav.documentation', 'Documentation')}
</NavLink>
<NavLink
to="/style-guide"
@@ -422,7 +430,7 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
<svg className="nav-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
<circle cx="13.5" cy="6.5" r="2.5"/><path d="M17 2H7a5 5 0 0 0-5 5v10a5 5 0 0 0 5 5h10a5 5 0 0 0 5-5V7a5 5 0 0 0-5-5z"/><path d="M9.5 14.5l-3 3"/><path d="M14.5 9.5l3-3"/>
</svg>
- Style Guide
+ {t('nav.styleGuide', 'Style Guide')}
</NavLink>
</>
)}
@@ -437,7 +445,7 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
<svg className="nav-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<path d="M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2"/><path d="M8.5 2h7"/><path d="M7 16h10"/>
</svg>
- Test Sandbox
+ {t('nav.testSandbox', 'Test Sandbox')}
</NavLink>
</nav>
</>
@@ -445,17 +453,17 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
<div className="sidebar-footer" ref={menuRef}>
{menuOpen && (
- <div className="user-context-menu" id="user-context-menu" aria-label="Account and preferences">
+ <div className="user-context-menu" id="user-context-menu" aria-label={t('nav.accountMenu', 'Account and preferences')}>
<div className="context-menu-section">
- <div className="context-menu-label" id="theme-switcher-label">Theme</div>
+ <div className="context-menu-label" id="theme-switcher-label">{t('nav.theme', 'Theme')}</div>
<div className="theme-switcher" role="group" aria-labelledby="theme-switcher-label">
<button
type="button"
className={`theme-btn ${theme === 'dark' ? 'active' : ''}`}
onClick={() => setTheme('dark')}
- aria-label="Dark theme"
+ aria-label={t('nav.themeDarkLong', 'Dark theme')}
aria-pressed={theme === 'dark'}
- title="Dark"
+ title={t('nav.themeDark', 'Dark')}
>
<Moon size={14} aria-hidden="true" />
</button>
@@ -463,9 +471,9 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
type="button"
className={`theme-btn ${theme === 'light' ? 'active' : ''}`}
onClick={() => setTheme('light')}
- aria-label="Light theme"
+ aria-label={t('nav.themeLightLong', 'Light theme')}
aria-pressed={theme === 'light'}
- title="Light"
+ title={t('nav.themeLight', 'Light')}
>
<Sun size={14} aria-hidden="true" />
</button>
@@ -473,24 +481,24 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
type="button"
className={`theme-btn ${theme === 'system' ? 'active' : ''}`}
onClick={() => setTheme('system')}
- aria-label="System theme"
+ aria-label={t('nav.themeSystemLong', 'System theme')}
aria-pressed={theme === 'system'}
- title="System"
+ title={t('nav.themeSystem', 'System')}
>
<Monitor size={14} aria-hidden="true" />
</button>
</div>
</div>
<div className="context-menu-section">
- <div className="context-menu-label" id="layout-switcher-label">Layout</div>
+ <div className="context-menu-label" id="layout-switcher-label">{t('nav.layout', 'Layout')}</div>
<div className="theme-switcher" role="group" aria-labelledby="layout-switcher-label">
<button
type="button"
className={`theme-btn ${layout === 'sidebar' ? 'active' : ''}`}
onClick={() => setLayout('sidebar')}
- aria-label="Sidebar layout"
+ aria-label={t('nav.layoutSidebarLong', 'Sidebar layout')}
aria-pressed={layout === 'sidebar'}
- title="Sidebar"
+ title={t('nav.layoutSidebar', 'Sidebar')}
>
<PanelLeft size={14} aria-hidden="true" />
</button>
@@ -498,9 +506,9 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
type="button"
className={`theme-btn ${layout === 'rail' ? 'active' : ''}`}
onClick={() => setLayout('rail')}
- aria-label="Compact rail layout"
+ aria-label={t('nav.layoutCompactLong', 'Compact rail layout')}
aria-pressed={layout === 'rail'}
- title="Compact"
+ title={t('nav.layoutCompact', 'Compact')}
>
<PanelLeftClose size={14} aria-hidden="true" />
</button>
@@ -508,16 +516,16 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
type="button"
className={`theme-btn ${layout === 'topbar' ? 'active' : ''}`}
onClick={() => setLayout('topbar')}
- aria-label="Top bar layout"
+ aria-label={t('nav.layoutTopbarLong', 'Top bar layout')}
aria-pressed={layout === 'topbar'}
- title="Top bar"
+ title={t('nav.layoutTopbar', 'Top bar')}
>
<PanelTop size={14} aria-hidden="true" />
</button>
</div>
</div>
<div className="context-menu-section">
- <div className="context-menu-label" id="sidebar-view-label">Sidebar View</div>
+ <div className="context-menu-label" id="sidebar-view-label">{t('nav.sidebarView', 'Sidebar View')}</div>
<div className="view-switcher" role="group" aria-labelledby="sidebar-view-label">
{Object.entries(SIDEBAR_PRESETS).map(([key, preset]) => (
<button
@@ -526,9 +534,9 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
className={`view-btn ${currentPreset === key ? 'active' : ''}`}
onClick={() => handlePresetSwitch(key)}
aria-pressed={currentPreset === key}
- title={preset.description}
+ title={label(preset, 'description')}
>
- {preset.label}
+ {label(preset)}
{currentPreset === key && <Check size={10} aria-hidden="true" />}
</button>
))}
@@ -541,7 +549,7 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
onClick={() => { navigate('/settings/appearance'); setMenuOpen(false); }}
>
<Palette size={15} aria-hidden="true" />
- Appearance
+ {t('nav.appearance', 'Appearance')}
<ChevronRight size={14} className="context-menu-arrow" aria-hidden="true" />
</button>
<button
@@ -550,7 +558,7 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
onClick={() => { navigate('/settings/sidebar'); setMenuOpen(false); }}
>
<PanelLeft size={15} aria-hidden="true" />
- Customize Sidebar
+ {t('nav.customizeSidebar', 'Customize Sidebar')}
<ChevronRight size={14} className="context-menu-arrow" aria-hidden="true" />
</button>
<button
@@ -559,13 +567,13 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
onClick={() => { navigate('/settings'); setMenuOpen(false); }}
>
<Settings size={15} aria-hidden="true" />
- All Settings
+ {t('nav.allSettings', 'All Settings')}
<ChevronRight size={14} className="context-menu-arrow" aria-hidden="true" />
</button>
<div className="context-menu-divider" />
<button type="button" className="context-menu-item danger" onClick={logout}>
<LogOut size={15} aria-hidden="true" />
- Log out
+ {t('common.actions.logOut', 'Log out')}
</button>
</div>
)}
@@ -583,7 +591,7 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {
</span>
<span className="user-meta">
<span className="user-handle">{user?.username || 'User'}</span>
- <span className="user-status">Online</span>
+ <span className="user-status">{t('nav.online', 'Online')}</span>
</span>
<ChevronUp size={14} className={`user-menu-arrow ${menuOpen ? 'open' : ''}`} aria-hidden="true" />
</button>
diff --git a/frontend/src/components/ds/PageTopbar.jsx b/frontend/src/components/ds/PageTopbar.jsx
index ceba04f3..d399ed45 100644
--- a/frontend/src/components/ds/PageTopbar.jsx
+++ b/frontend/src/components/ds/PageTopbar.jsx
@@ -4,6 +4,7 @@ import { MoreHorizontal } from 'lucide-react';
import { Popover, PopoverTrigger, PopoverContent } from '@/components/ui/popover';
import { cn } from '@/lib/utils';
import { useOverflowItems } from '@/hooks/useOverflowItems';
+import { t } from '@/i18n';
// The demo's page top bar (see docs/REDESIGN_MAP.md §6 decision 3): infra pages
// carry their own top bar — an icon + title, an optional routed sub-nav that
@@ -40,7 +41,7 @@ export function PageTopbar({ icon, title, meta, tabs, actions, className, navLab
many sections — e.g. Security — stay on one row). Pages without
tabs keep the plain spacer that pushes actions to the right. */}
{hasTabs
- ? <TopbarTabs tabs={tabs} label={navLabel || title || 'Page'} />
+ ? <TopbarTabs tabs={tabs} label={navLabel || title || t('common.page', 'Page')} />
: <div className="sk-topbar__spacer" />}
{actions && <div className="sk-topbar__actions">{actions}</div>}
@@ -105,10 +106,10 @@ function TopbarTabs({ tabs, label }) {
ref={moreBtnRef}
type="button"
className="sk-topbar__tab sk-topbar__more"
- aria-label="More sections"
+ aria-label={t('common.moreSections', 'More sections')}
>
<MoreHorizontal size={16} />
- More
+ {t('common.more', 'More')}
</button>
</PopoverTrigger>
<PopoverContent align="end" sideOffset={6} className="ui-popover-content">
diff --git a/frontend/src/components/sidebarItems.js b/frontend/src/components/sidebarItems.js
index 804f1952..fd844efb 100644
--- a/frontend/src/components/sidebarItems.js
+++ b/frontend/src/components/sidebarItems.js
@@ -16,6 +16,9 @@ const groupPrefixes = (tabs) => tabs.map((t) => t.to);
export const SIDEBAR_CATEGORIES = ['overview', 'infrastructure', 'operations', 'system'];
+// Category headings. Keys resolve at RENDER, not at import: a label
+// translated at module load would translate once and never follow a locale
+// switch (plan 79 §E).
export const CATEGORY_LABELS = {
overview: 'Overview',
infrastructure: 'Infrastructure',
@@ -23,9 +26,17 @@ export const CATEGORY_LABELS = {
system: 'System'
};
+export const CATEGORY_LABEL_KEYS = {
+ overview: 'nav.category.overview',
+ infrastructure: 'nav.category.infrastructure',
+ operations: 'nav.category.operations',
+ system: 'nav.category.system'
+};
+
export const SIDEBAR_ITEMS = [
{
id: 'dashboard',
+ labelKey: 'nav.dashboard',
label: 'Dashboard',
route: '/',
category: 'overview',
@@ -41,6 +52,7 @@ export const SIDEBAR_ITEMS = [
// page's PageTopbar (ORG_TABS via TabGroupLayout). matchPrefixes keeps
// the single sidebar item lit across all three routes.
id: 'organization',
+ labelKey: 'nav.organization',
label: 'Organization',
route: '/projects',
matchPrefixes: groupPrefixes(ORG_TABS),
@@ -55,6 +67,7 @@ export const SIDEBAR_ITEMS = [
// /server-templates are unchanged and reachable from those tabs.
// (Fleet Monitor left this group for /monitoring.)
id: 'servers',
+ labelKey: 'nav.servers',
label: 'Servers',
route: '/servers',
// Keep "Servers" lit across the whole tab group (Agent Fleet, Fleet
@@ -69,6 +82,7 @@ export const SIDEBAR_ITEMS = [
// bar (PageTopbar tabs), not as sidebar sub-items. Routes /dns and /ssl
// are unchanged and still reachable from those tabs.
id: 'domains',
+ labelKey: 'nav.domains',
label: 'Domains',
route: '/domains',
matchPrefixes: groupPrefixes(DOMAIN_TABS),
@@ -81,6 +95,7 @@ export const SIDEBAR_ITEMS = [
// bar (PageTopbar SERVICE_TABS), not as sidebar sub-items. Routes
// /services/new, /templates, /deployments are unchanged.
id: 'services',
+ labelKey: 'nav.services',
label: 'Services',
route: '/services',
matchPrefixes: groupPrefixes(SERVICE_TABS),
@@ -96,6 +111,7 @@ export const SIDEBAR_ITEMS = [
// item comes from the extension manifest.
{
id: 'databases',
+ labelKey: 'nav.databases',
label: 'Databases',
route: '/databases',
category: 'infrastructure',
@@ -103,6 +119,7 @@ export const SIDEBAR_ITEMS = [
},
{
id: 'docker',
+ labelKey: 'nav.docker',
label: 'Docker',
route: '/docker',
category: 'infrastructure',
@@ -119,6 +136,7 @@ export const SIDEBAR_ITEMS = [
// FTP Server now lives in the page's top bar (PageTopbar FILE_TABS), not
// as a sidebar sub-item. Route /ftp is unchanged, reachable from the tab.
id: 'files',
+ labelKey: 'nav.files',
label: 'Files',
route: '/files',
matchPrefixes: groupPrefixes(FILE_TABS),
@@ -134,6 +152,7 @@ export const SIDEBAR_ITEMS = [
// page. Labelled "Monitoring" to match the route and the page — this
// used to say "Observability", which named the same thing twice.
id: 'monitoring',
+ labelKey: 'nav.monitoring',
label: 'Monitoring',
route: '/monitoring',
matchPrefixes: groupPrefixes(MONITOR_TABS),
@@ -142,6 +161,7 @@ export const SIDEBAR_ITEMS = [
},
{
id: 'backups',
+ labelKey: 'nav.backups',
label: 'Backups',
route: '/backups',
category: 'operations',
@@ -149,6 +169,7 @@ export const SIDEBAR_ITEMS = [
},
{
id: 'cron',
+ labelKey: 'nav.cron',
label: 'Cron Jobs',
route: '/cron',
category: 'operations',
@@ -156,6 +177,7 @@ export const SIDEBAR_ITEMS = [
},
{
id: 'security',
+ labelKey: 'nav.security',
label: 'Security',
route: '/security',
category: 'operations',
@@ -165,6 +187,7 @@ export const SIDEBAR_ITEMS = [
// is contributed by the extension manifest.
{
id: 'queue',
+ labelKey: 'nav.queue',
label: 'Queue Bus',
route: '/queue',
category: 'operations',
@@ -172,6 +195,7 @@ export const SIDEBAR_ITEMS = [
},
{
id: 'terminal',
+ labelKey: 'nav.terminal',
label: 'Terminal / Logs',
route: '/terminal',
category: 'system',
@@ -194,6 +218,7 @@ export const SIDEBAR_ITEMS = [
// Downloads now lives in the page's top bar (PageTopbar MARKET_TABS), not
// as a sidebar sub-item. Route /downloads is unchanged.
id: 'marketplace',
+ labelKey: 'nav.marketplace',
label: 'Extensions',
route: '/extensions',
matchPrefixes: groupPrefixes(MARKET_TABS),
@@ -217,32 +242,44 @@ export const ADVANCED_ITEM_IDS = ['queue'];
// Preset profiles define which items are hidden (top-level only)
export const SIDEBAR_PRESETS = {
recommended: {
+ labelKey: 'nav.preset.recommended.label',
label: 'Recommended',
+ descriptionKey: 'nav.preset.recommended.description',
description: 'Everyday essentials — advanced tools hidden',
hiddenItems: [...ADVANCED_ITEM_IDS]
},
full: {
+ labelKey: 'nav.preset.full.label',
label: 'Full',
+ descriptionKey: 'nav.preset.full.description',
description: 'All sidebar items visible',
hiddenItems: []
},
web: {
+ labelKey: 'nav.preset.web.label',
label: 'Web Hosting',
+ descriptionKey: 'nav.preset.web.description',
description: 'Domains, SSL, databases, and web essentials',
hiddenItems: ['docker', 'git', 'workflow', 'email', ...ADVANCED_ITEM_IDS]
},
email: {
+ labelKey: 'nav.preset.email.label',
label: 'Email Admin',
+ descriptionKey: 'nav.preset.email.description',
description: 'Email server, security, DNS, and monitoring',
hiddenItems: ['services', 'workflow', 'databases', 'docker', 'git', 'cron', ...ADVANCED_ITEM_IDS]
},
devops: {
+ labelKey: 'nav.preset.devops.label',
label: 'Docker / DevOps',
+ descriptionKey: 'nav.preset.devops.description',
description: 'Docker, Git, monitoring, and CI/CD tools',
hiddenItems: ['email', ...ADVANCED_ITEM_IDS]
},
minimal: {
+ labelKey: 'nav.preset.minimal.label',
label: 'Minimal',
+ descriptionKey: 'nav.preset.minimal.description',
description: 'Core only — no databases, containers, or scheduling',
hiddenItems: ['workflow', 'databases', 'docker', 'git', 'email', 'cron', ...ADVANCED_ITEM_IDS]
}
diff --git a/frontend/src/i18n/index.js b/frontend/src/i18n/index.js
index f26bccf2..bfbb6643 100644
--- a/frontend/src/i18n/index.js
+++ b/frontend/src/i18n/index.js
@@ -46,6 +46,16 @@ i18next
react: { useSuspense: false },
});
+/**
+ * Translate outside React — class components (ErrorBoundary), module-level
+ * tables, non-component helpers.
+ *
+ * A bare export rather than reaching for `i18next.t` at the call site: the
+ * extractor collects bare `t(...)` calls, so a member call would leave that
+ * copy out of en.json and quietly untranslatable.
+ */
+export const t = (...args) => i18next.t(...args);
+
/**
* Make a locale's bundle available, importing it on first use.
* Resolves to the code actually loaded — `en` if the bundle is missing, so a
diff --git a/frontend/src/i18n/labels.js b/frontend/src/i18n/labels.js
new file mode 100644
index 00000000..414981e1
--- /dev/null
+++ b/frontend/src/i18n/labels.js
@@ -0,0 +1,34 @@
+import { useCallback } from 'react';
+import { useTranslation } from 'react-i18next';
+
+/**
+ * Resolve a declaratively-keyed label from a data object (plan 79 §E).
+ *
+ * Data tables — sidebar items, tab tables, column definitions, wizard steps —
+ * carry the pair
+ *
+ * { labelKey: 'nav.dashboard', label: 'Dashboard' }
+ *
+ * rather than a `t()` call, because a `t()` in a module-level table resolves
+ * ONCE at import and then never follows a locale switch. The extractor reads
+ * the pair at its declaration site; this resolves it at render.
+ *
+ * An item with no key (an extension-contributed nav entry, for instance) falls
+ * back to its raw label rather than rendering blank.
+ */
+export function translateLabel(t, item, field = 'label') {
+ if (!item) return '';
+ const fallback = item[field];
+ const key = item[`${field}Key`];
+ if (!key) return fallback ?? '';
+ return t(key, { defaultValue: fallback ?? '' });
+}
+
+/** Hook form — re-renders with the active locale. */
+export default function useLabel() {
+ const { t } = useTranslation();
+ return useCallback(
+ (item, field = 'label') => translateLabel(t, item, field),
+ [t],
+ );
+}
diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json
index f6ce6a93..4f703a5f 100644
--- a/frontend/src/i18n/locales/en.json
+++ b/frontend/src/i18n/locales/en.json
@@ -1,5 +1,13 @@
{
"common": {
+ "actions": {
+ "logOut": "Log out",
+ "retry": "Retry",
+ "tryAgain": "Try again"
+ },
+ "confirm": {
+ "typeToConfirm": "Type <0>{{value}}</0> to confirm:"
+ },
"duration": {
"hours": "{{count}}h",
"hoursMinutes": "{{hours}}h {{minutes}}m",
@@ -7,11 +15,122 @@
"minutesSeconds": "{{minutes}}m {{seconds}}s",
"seconds": "{{count}}s"
},
+ "error": {
+ "failedToLoad": "Failed to load",
+ "loadingData": "An error occurred while loading data",
+ "title": "Something went wrong",
+ "unexpected": "An unexpected error occurred"
+ },
+ "more": "More",
+ "moreSections": "More sections",
+ "page": "Page",
+ "state": {
+ "loading": "Loading",
+ "loadingApp": "Loading ServerKit",
+ "noResults": "No results found"
+ },
"time": {
"daysShort": "{{count}}d",
"hoursShort": "{{count}}h",
"justNow": "just now",
"minutesShort": "{{count}}m"
}
+ },
+ "nav": {
+ "accountMenu": "Account and preferences",
+ "allSettings": "All Settings",
+ "appMap": "App Map",
+ "appearance": "Appearance",
+ "backups": "Backups",
+ "brand": "Brand",
+ "closeMenu": "Close navigation menu",
+ "collapseGroup": "Collapse {{group}}",
+ "cron": "Cron Jobs",
+ "customizeSidebar": "Customize Sidebar",
+ "dashboard": "Dashboard",
+ "databases": "Databases",
+ "devTools": "Dev Tools",
+ "docker": "Docker",
+ "documentation": "Documentation",
+ "domains": "Domains",
+ "expandGroup": "Expand {{group}}",
+ "files": "Files",
+ "layout": "Layout",
+ "layoutCompact": "Compact",
+ "layoutCompactLong": "Compact rail layout",
+ "layoutSidebar": "Sidebar",
+ "layoutSidebarLong": "Sidebar layout",
+ "layoutTopbar": "Top bar",
+ "layoutTopbarLong": "Top bar layout",
+ "mainNavigation": "Main navigation",
+ "marketplace": "Extensions",
+ "monitoring": "Monitoring",
+ "online": "Online",
+ "openMenu": "Open navigation menu",
+ "organization": "Organization",
+ "preset": {
+ "devops": {
+ "description": "Docker, Git, monitoring, and CI/CD tools",
+ "label": "Docker / DevOps"
+ },
+ "email": {
+ "description": "Email server, security, DNS, and monitoring",
+ "label": "Email Admin"
+ },
+ "full": {
+ "description": "All sidebar items visible",
+ "label": "Full"
+ },
+ "minimal": {
+ "description": "Core only — no databases, containers, or scheduling",
+ "label": "Minimal"
+ },
+ "recommended": {
+ "description": "Everyday essentials — advanced tools hidden",
+ "label": "Recommended"
+ },
+ "web": {
+ "description": "Domains, SSL, databases, and web essentials",
+ "label": "Web Hosting"
+ }
+ },
+ "queue": "Queue Bus",
+ "security": "Security",
+ "servers": "Servers",
+ "services": "Services",
+ "sidebarView": "Sidebar View",
+ "starOnGithub": "Star on GitHub",
+ "starOnGithubLong": "Star ServerKit on GitHub",
+ "styleGuide": "Style Guide",
+ "terminal": "Terminal / Logs",
+ "testSandbox": "Test Sandbox",
+ "theme": "Theme",
+ "themeDark": "Dark",
+ "themeDarkLong": "Dark theme",
+ "themeLight": "Light",
+ "themeLightLong": "Light theme",
+ "themeSystem": "System",
+ "themeSystemLong": "System theme"
+ },
+ "notifications": {
+ "bell": "Notifications",
+ "bellUnread": "Notifications, {{count}} unread",
+ "dismissItem": "Dismiss {{title}}",
+ "empty": "You’re all caught up.",
+ "heading": "Notifications",
+ "markAllRead": "Mark all read",
+ "seeAll": "See all notifications"
+ },
+ "palette": {
+ "docs": {
+ "deploySources": "Docs: Deploy sources",
+ "extensions": "Docs: Extensions",
+ "extensionsBuilding": "Docs: Building extensions",
+ "extensionsInstalling": "Docs: Installing extensions",
+ "extensionsPublishing": "Docs: Publishing extensions",
+ "extensionsSecurity": "Docs: Extension security",
+ "manifest": "Docs: serverkit.yaml manifest"
+ },
+ "label": "Command palette"
}
}
diff --git a/frontend/src/i18n/locales/es.json b/frontend/src/i18n/locales/es.json
index f7a16b70..2ad76d9b 100644
--- a/frontend/src/i18n/locales/es.json
+++ b/frontend/src/i18n/locales/es.json
@@ -1,5 +1,13 @@
{
"common": {
+ "actions": {
+ "logOut": "Cerrar sesión",
+ "retry": "Reintentar",
+ "tryAgain": "Reintentar"
+ },
+ "confirm": {
+ "typeToConfirm": "Escribe <0>{{value}}</0> para confirmar:"
+ },
"duration": {
"hours": "{{count}} h",
"hoursMinutes": "{{hours}} h {{minutes}} min",
@@ -7,11 +15,122 @@
"minutesSeconds": "{{minutes}} min {{seconds}} s",
"seconds": "{{count}} s"
},
+ "error": {
+ "failedToLoad": "No se pudo cargar",
+ "loadingData": "Se produjo un error al cargar los datos",
+ "title": "Algo salió mal",
+ "unexpected": "Se produjo un error inesperado"
+ },
+ "more": "Más",
+ "moreSections": "Más secciones",
+ "page": "Página",
+ "state": {
+ "loading": "Cargando",
+ "loadingApp": "Cargando ServerKit",
+ "noResults": "No se encontraron resultados"
+ },
"time": {
"daysShort": "{{count}} d",
"hoursShort": "{{count}} h",
"justNow": "ahora mismo",
"minutesShort": "{{count}} min"
}
+ },
+ "nav": {
+ "accountMenu": "Cuenta y preferencias",
+ "allSettings": "Todos los ajustes",
+ "appMap": "Mapa de la app",
+ "appearance": "Apariencia",
+ "backups": "Copias de seguridad",
+ "brand": "Marca",
+ "closeMenu": "Cerrar el menú de navegación",
+ "collapseGroup": "Contraer {{group}}",
+ "cron": "Tareas programadas",
+ "customizeSidebar": "Personalizar la barra lateral",
+ "dashboard": "Panel",
+ "databases": "Bases de datos",
+ "devTools": "Herramientas de desarrollo",
+ "docker": "Docker",
+ "documentation": "Documentación",
+ "domains": "Dominios",
+ "expandGroup": "Expandir {{group}}",
+ "files": "Archivos",
+ "layout": "Diseño",
+ "layoutCompact": "Compacto",
+ "layoutCompactLong": "Diseño de barra compacta",
+ "layoutSidebar": "Barra lateral",
+ "layoutSidebarLong": "Diseño con barra lateral",
+ "layoutTopbar": "Barra superior",
+ "layoutTopbarLong": "Diseño con barra superior",
+ "mainNavigation": "Navegación principal",
+ "marketplace": "Extensiones",
+ "monitoring": "Monitorización",
+ "online": "En línea",
+ "openMenu": "Abrir el menú de navegación",
+ "organization": "Organización",
+ "preset": {
+ "devops": {
+ "description": "Docker, Git, monitorización y herramientas CI/CD",
+ "label": "Docker / DevOps"
+ },
+ "email": {
+ "description": "Servidor de correo, seguridad, DNS y monitorización",
+ "label": "Administración de correo"
+ },
+ "full": {
+ "description": "Todos los elementos de la barra lateral visibles",
+ "label": "Completo"
+ },
+ "minimal": {
+ "description": "Solo lo esencial: sin bases de datos, contenedores ni programación",
+ "label": "Mínimo"
+ },
+ "recommended": {
+ "description": "Lo esencial del día a día: las herramientas avanzadas quedan ocultas",
+ "label": "Recomendado"
+ },
+ "web": {
+ "description": "Dominios, SSL, bases de datos y lo esencial para la web",
+ "label": "Alojamiento web"
+ }
+ },
+ "queue": "Bus de colas",
+ "security": "Seguridad",
+ "servers": "Servidores",
+ "services": "Servicios",
+ "sidebarView": "Vista de la barra lateral",
+ "starOnGithub": "Marcar con estrella en GitHub",
+ "starOnGithubLong": "Marcar ServerKit con estrella en GitHub",
+ "styleGuide": "Guía de estilo",
+ "terminal": "Terminal / Registros",
+ "testSandbox": "Entorno de pruebas",
+ "theme": "Tema",
+ "themeDark": "Oscuro",
+ "themeDarkLong": "Tema oscuro",
+ "themeLight": "Claro",
+ "themeLightLong": "Tema claro",
+ "themeSystem": "Sistema",
+ "themeSystemLong": "Tema del sistema"
+ },
+ "notifications": {
+ "bell": "Notificaciones",
+ "bellUnread": "Notificaciones, {{count}} sin leer",
+ "dismissItem": "Descartar {{title}}",
+ "empty": "No tienes nada pendiente.",
+ "heading": "Notificaciones",
+ "markAllRead": "Marcar todo como leído",
+ "seeAll": "Ver todas las notificaciones"
+ },
+ "palette": {
+ "docs": {
+ "deploySources": "Documentación: Orígenes de despliegue",
+ "extensions": "Documentación: Extensiones",
+ "extensionsBuilding": "Documentación: Crear extensiones",
+ "extensionsInstalling": "Documentación: Instalar extensiones",
+ "extensionsPublishing": "Documentación: Publicar extensiones",
+ "extensionsSecurity": "Documentación: Seguridad de las extensiones",
+ "manifest": "Documentación: Manifiesto serverkit.yaml"
+ },
+ "label": "Paleta de comandos"
}
}