From e6fdb39a86e078b46d262e4504e6c081f9681068 Mon Sep 17 00:00:00 2001 From: Agent Zero Date: Sat, 29 Aug 2026 03:05:27 +0200 Subject: [PATCH] task(H4): i18n foundation - strings.ts de/en maps, t() with key fallback, language persistence, useT hook, LayoutBar + Topbar texts switched --- frontend/src/components/LayoutBar.tsx | 17 +++-- frontend/src/components/Topbar.tsx | 7 +- frontend/src/i18n/strings.ts | 105 ++++++++++++++++++++++++++ frontend/tests/i18n.test.tsx | 93 +++++++++++++++++++++++ 4 files changed, 213 insertions(+), 9 deletions(-) create mode 100644 frontend/src/i18n/strings.ts create mode 100644 frontend/tests/i18n.test.tsx diff --git a/frontend/src/components/LayoutBar.tsx b/frontend/src/components/LayoutBar.tsx index a335836..768f45d 100644 --- a/frontend/src/components/LayoutBar.tsx +++ b/frontend/src/components/LayoutBar.tsx @@ -11,6 +11,7 @@ import type { LayoutDefinition } from '../types/cad.types'; import { getActiveDocument, onActiveDocumentChanged } from '../kernel/document/documentService'; import { insertTitleBlockForLayout } from '../services/titleBlockService'; import { printLayout } from '../services/printService'; +import { useT } from '../i18n/strings'; export interface LayoutView { center: { x: number; y: number }; @@ -80,6 +81,8 @@ const WIDGET_W = 100; const WIDGET_H = 80; const LayoutBar: React.FC = ({ doc: docProp, bridge: bridgeProp }) => { + const t = useT(); + const [doc, setDoc] = useState(docProp ?? getActiveDocument()); const [layouts, setLayouts] = useState([]); @@ -134,23 +137,23 @@ const LayoutBar: React.FC = ({ doc: docProp, bridge: bridgeProp return (
- Layouts + {t('layouts.title')}
{layouts.length === 0 ? ( -
Keine Layouts
+
{t('layouts.empty')}
) : (
{layouts.map((l) => { @@ -161,7 +164,7 @@ const LayoutBar: React.FC = ({ doc: docProp, bridge: bridgeProp type="button" className="layout-bar-entry" data-testid={`layout-entry-${l.id}`} - title={`Zoom zu ${l.name}`} + title={t('layouts.zoomto', l.name)} onClick={() => handleZoomTo(l)} > = ({ doc: docProp, bridge: bridgeProp
diff --git a/frontend/src/components/Topbar.tsx b/frontend/src/components/Topbar.tsx index b67416c..197f88f 100644 --- a/frontend/src/components/Topbar.tsx +++ b/frontend/src/components/Topbar.tsx @@ -2,12 +2,15 @@ import React from 'react'; import type { TopbarProps } from '../types/ui.types'; import type { UnitType } from '../utils/format'; import { useUIMode, toggleUIMode, getUIMode } from '../services/uiModeService'; +import { useT } from '../i18n/strings'; const Topbar: React.FC = ({ projectName, savedStatus, onUndo, onRedo, onThemeToggle, theme, onOpenSettings, onOpenLeftDrawer, onOpenRightDrawer, unit = 'mm', onUnitChange, onNavigateBack, }) => { + const t = useT(); + const uiMode = useUIMode(); return ( @@ -38,8 +41,8 @@ const Topbar: React.FC = ({