From 4a3aee76913c59785443a353e7230eee730478ab Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Tue, 26 May 2026 14:40:56 +0200 Subject: [PATCH] fix(locale): align DE/EN component structures, fix dynamic language switcher slug mapping, and localize referenzen map --- app/[locale]/referenzen/page.tsx | 6 +- components/layout/LanguageSwitcher.test.tsx | 70 +++++++++++++++++++++ components/layout/LanguageSwitcher.tsx | 54 +++++++++++++++- content/en/bohrtechnik.mdx | 35 ++++++++--- content/en/glasfaser.mdx | 35 ++++++++--- content/en/kabeltiefbau.mdx | 42 +++++++++---- content/en/planung.mdx | 45 ++++++++----- content/en/ueber-uns.mdx | 10 --- content/en/vermessung.mdx | 43 +++++++++---- scripts/compare-mdx-parity.ts | 52 +++++++++++++++ 10 files changed, 325 insertions(+), 67 deletions(-) create mode 100644 components/layout/LanguageSwitcher.test.tsx create mode 100644 scripts/compare-mdx-parity.ts diff --git a/app/[locale]/referenzen/page.tsx b/app/[locale]/referenzen/page.tsx index b2d449a1a..a3960b215 100644 --- a/app/[locale]/referenzen/page.tsx +++ b/app/[locale]/referenzen/page.tsx @@ -75,9 +75,9 @@ export default async function ReferenzenOverview(props: { params: Promise<{ loca {/* Map Hero Section */} Erfolgreich umgesetzte
Projekte.} - description="Vom Breitbandausbau bis zur komplexen 110kV-Trasse: Ein Auszug unserer bundesweiten Projekte, bei denen wir Infrastruktur für die Zukunft geschaffen haben. Entdecken Sie unsere Standorte." + badge={locale === 'en' ? 'Our References' : 'Unsere Referenzen'} + title={locale === 'en' ? <>Successfully realized
projects. : <>Erfolgreich umgesetzte
Projekte.} + description={locale === 'en' ? 'From broadband expansion to complex 110kV lines: A selection of our nationwide projects where we have created infrastructure for the future. Discover our locations.' : 'Vom Breitbandausbau bis zur komplexen 110kV-Trasse: Ein Auszug unserer bundesweiten Projekte, bei denen wir Infrastruktur für die Zukunft geschaffen haben. Entdecken Sie unsere Standorte.'} locations={enrichedLocations} /> diff --git a/components/layout/LanguageSwitcher.test.tsx b/components/layout/LanguageSwitcher.test.tsx new file mode 100644 index 000000000..67e6cd728 --- /dev/null +++ b/components/layout/LanguageSwitcher.test.tsx @@ -0,0 +1,70 @@ +import * as React from 'react'; +import { describe, it, expect, vi, beforeEach } from 'vitest'; +import { render, screen } from '@testing-library/react'; +import { LanguageSwitcher } from './LanguageSwitcher'; +import { usePathname } from 'next/navigation'; + +// Mock next/navigation +vi.mock('next/navigation', () => ({ + usePathname: vi.fn(), +})); + +// Mock TransitionLink to render standard anchor tag and forward all props +vi.mock('@/components/ui/TransitionLink', () => ({ + TransitionLink: ({ children, href, onClick, ...props }: any) => ( + + {children} + + ), +})); + +// Mock HoverShineOverlay +vi.mock('@/components/ui/HoverShineOverlay', () => ({ + HoverShineOverlay: () =>
, +})); + +describe('LanguageSwitcher TDD', () => { + beforeEach(() => { + vi.clearAllMocks(); + }); + + it('translates /en/events to /de/messen when switching to German', () => { + vi.mocked(usePathname).mockReturnValue('/en/events'); + render(); + + const deLink = screen.getByLabelText('Switch to Deutsch'); + expect(deLink.getAttribute('href')).toBe('/de/messen'); + }); + + it('translates /de/messen to /en/events when switching to English', () => { + vi.mocked(usePathname).mockReturnValue('/de/messen'); + render(); + + const enLink = screen.getByLabelText('Switch to English'); + expect(enLink.getAttribute('href')).toBe('/en/events'); + }); + + it('translates /en/about-us to /de/ueber-uns when switching to German', () => { + vi.mocked(usePathname).mockReturnValue('/en/about-us'); + render(); + + const deLink = screen.getByLabelText('Switch to Deutsch'); + expect(deLink.getAttribute('href')).toBe('/de/ueber-uns'); + }); + + it('translates /de/ueber-uns to /en/about-us when switching to English', () => { + vi.mocked(usePathname).mockReturnValue('/de/ueber-uns'); + render(); + + const enLink = screen.getByLabelText('Switch to English'); + expect(enLink.getAttribute('href')).toBe('/en/about-us'); + }); + + it('preserves nested paths like blog posts', () => { + vi.mocked(usePathname).mockReturnValue('/de/blog/some-post'); + render(); + + const enLink = screen.getByLabelText('Switch to English'); + expect(enLink.getAttribute('href')).toBe('/en/blog/some-post'); + }); +}); diff --git a/components/layout/LanguageSwitcher.tsx b/components/layout/LanguageSwitcher.tsx index 3f702342a..faa650988 100644 --- a/components/layout/LanguageSwitcher.tsx +++ b/components/layout/LanguageSwitcher.tsx @@ -3,6 +3,41 @@ import { TransitionLink } from '@/components/ui/TransitionLink'; import { usePathname } from 'next/navigation'; import { HoverShineOverlay } from '@/components/ui/HoverShineOverlay'; +import enMessages from '@/messages/en.json'; +import deMessages from '@/messages/de.json'; + +const getMessages = (locale: string) => { + return locale === 'de' ? deMessages : enMessages; +}; + +// Synchronous version of mapSlugToFileSlug +function syncMapSlugToFileSlug(translatedSlug: string, locale: string): string { + const messages = getMessages(locale); + const slugs = messages.Slugs; + + if (slugs.pages && translatedSlug in slugs.pages) { + return slugs.pages[translatedSlug as keyof typeof slugs.pages]; + } + return translatedSlug; +} + +// Synchronous version of mapFileSlugToTranslated +function syncMapFileSlugToTranslated(fileSlug: string, locale: string): string { + const messages = getMessages(locale); + const slugs = messages.Slugs; + + const sections = [slugs.pages]; + for (const sectionData of sections) { + if (sectionData && typeof sectionData === 'object') { + for (const [translatedSlug, mappedSlug] of Object.entries(sectionData)) { + if (mappedSlug === fileSlug) { + return translatedSlug; + } + } + } + } + return fileSlug; +} interface LanguageSwitcherProps { mobile?: boolean; @@ -14,8 +49,23 @@ export function LanguageSwitcher({ mobile = false, isSolidMode = false }: Langua const currentLocale = pathname.startsWith('/en') ? 'en' : 'de'; const getSwitchedUrl = (newLocale: string) => { - const pathWithoutLocale = pathname.replace(/^\/(en|de)/, ''); - return `/${newLocale}${pathWithoutLocale === '' ? '' : pathWithoutLocale}`; + const segments = pathname.split('/').filter(Boolean); + if (segments.length === 0) { + return `/${newLocale}`; + } + + const currentLoc = segments[0] === 'en' || segments[0] === 'de' ? segments[0] : 'de'; + const hasLocale = segments[0] === 'en' || segments[0] === 'de'; + const pathSegments = hasLocale ? segments.slice(1) : segments; + + if (pathSegments.length === 1) { + const slug = pathSegments[0]; + const fileSlug = syncMapSlugToFileSlug(slug, currentLoc); + const translatedSlug = syncMapFileSlugToTranslated(fileSlug, newLocale); + return `/${newLocale}/${translatedSlug}`; + } + + return `/${newLocale}/${pathSegments.join('/')}`; }; const locales = [ diff --git a/content/en/bohrtechnik.mdx b/content/en/bohrtechnik.mdx index ac31b604d..686b770b5 100644 --- a/content/en/bohrtechnik.mdx +++ b/content/en/bohrtechnik.mdx @@ -1,7 +1,7 @@ --- title: "Trenchless Line Laying" date: "2024-03-20" -excerpt: "Precise horizontal directional drilling and earth rockets in all soil classes for surface-friendly and trenchless line laying." +excerpt: "Precise horizontal directional drilling and earth rockets in all soil classes for surface-friendly and efficient line laying." layout: "fullBleed" --- @@ -15,12 +15,29 @@ layout: "fullBleed" ctaHref="/en/kontakt" /> +
+
+ If classic trench construction is out of the question for space, environmental or cost reasons, we rely on the most modern trenchless techniques. We protect nature and minimize restoration costs. +
+ + ## Maximum Efficiency, Minimal Intervention + + Trenchless line laying is the smartest solution for complex construction projects. This process shows its absolute strengths particularly when crossing highly frequented roads, railway lines, highways or sensitive bodies of water. Traffic continues to flow, nature remains untouched and complex surfaces such as expensive paving or asphalt do not have to be destroyed. + + ## HDD Boreholes and Earth Rockets + + With our specialized machinery, we master a wide variety of processes. With the **Horizontal Directional Drilling (HDD) process**, we steer the drill head precisely underground. We achieve drilling lengths of up to 250 meters in one piece and can pull in protective pipes with a diameter of up to 400 mm. + + For shorter distances, such as fast and gentle house connections, we use our **earth rockets** (soil displacement method). Here we achieve drilling lengths of up to 15 meters for pipes up to 160 mm in diameter - ideal for leaving front gardens and driveways completely intact. + + +
+ - + +
+
+ A life without electricity or high-speed internet is unimaginable today - that is why we lay cables. We build the backbone of the digital society. +
+ + ## The Backbone of Digitalization + + Fast internet and state-of-the-art telecommunications networks require an absolutely smooth and highly professional network expansion. With highly specialized assembly teams and our own modern fleet of machinery, E-TIB ensures the highest execution quality in nationwide fiber optic expansion. + + ## FTTX Expansion from a Single Source + + As a powerful partner for telecommunications providers, we cover every step of physical network creation. We take over the construction of complete empty conduit routes as well as cable and pipe trenches. In addition, we position and build multi-function enclosures at strategic network nodes. + + Our service does not end with pure civil engineering: We take care of the professional pulling and blowing in of highly sensitive fiber optic and telecommunication cables over long distances and carry out all required cable assemblies. In this way, we guarantee that the digital infrastructure can go into operation safely and performantly. +
+ + + +
+
+ Everywhere digging and drilling is happening, but unfortunately a lot also goes wrong. We focus on quality, the highest safety standards and legally compliant documentation - so that your construction project does not turn into a cost trap. +
+ + ## Quality instead of a Cost Trap + + On many construction sites, cheap providers from abroad are increasingly being used, which often leads to **safety standards and documentation requirements being ignored**. The consequences are severe: accidents, damaged external lines (such as electricity, water and gas) as well as massive construction delays and expensive supplements. A supposed bargain quickly turns out to be a financial burden. + + Particularly for funded infrastructure projects, retrieving the funding is extremely problematic without absolutely seamless, standard-compliant documentation. + + ## Everything from a Single Source + + Thanks to our many years of experience, we identify problems early on and work out safe and satisfactory solutions for our clients in advance. E-TIB GmbH has fully specialized in cable civil engineering. + + We offer you the complete range of services for the construction of cable routes from a single source - with our own ultra-modern machine fleet and permanent specialist staff from the region. In direct cooperation with our partner office, E-TIB Ingenieurgesellschaft mbH, we can also rule out planning errors at an early stage and sovereignly meet even the most complex documentation requirements. + + +
+ - + +
+
+ We offer our clients everything from a single source - from the rough planning of your project idea and cable civil engineering to the construction of your renewable energy project. +
+ + ## Foundation for Project Success + + Solid planning is the crucial foundation for every successful infrastructure project. Projects often fail or are massively delayed because the complexity of civil engineering planning and approval procedures was underestimated. Through our combined competence, you avoid expensive planning errors and frictional losses at the interfaces. + + Both for the highly topical broadband expansion and for the demanding grid connection of solar or wind projects, absolutely precise and high-quality cable route planning is required. To do this, we inspect the route on site, analyze all potential construction conflicts at an early stage and ensure that all necessary applications for the laying are submitted completely and on time to the authorities. + + ## Strong Engineering Competence + + In close cooperation with our specialized partner engineering firm, **E-TIB Ingenieurgesellschaft mbH**, we accompany you through all service phases. Whether structural planning for route optimization, complex approval planning or detailed execution planning - we steer your project from the first feasibility study to successful construction supervision and acceptance. +
+ + + diff --git a/content/en/ueber-uns.mdx b/content/en/ueber-uns.mdx index 649fffcd8..27f273f32 100644 --- a/content/en/ueber-uns.mdx +++ b/content/en/ueber-uns.mdx @@ -89,16 +89,6 @@ layout: "fullBleed" ]} /> -Nationwide
at your service.} - description="From our strategic locations in Guben and Bülstedt, we control and realize complex infrastructure projects across the entire federal territory." - stats={[ - { value: '100', suffix: '%', label: 'Nationwide Reach' }, - { value: '2', suffix: '+', label: 'Operating Locations' } - ]} -/> -
+
+
+ We work with highly precise GPS equipment for the seamless documentation of our clients' projects. For this purpose, we independently develop app integrations to automate surveying. +
+ + ## Highest Precision Protects Against Surprises + + In today's times, legal documentation requirements and strict safety standards are growing rapidly. Many conventional civil engineering companies are hardly able to cleanly meet these highly complex requirements - especially for funded broadband expansion. Missing or incorrect documentation inevitably leads to massive problems during construction acceptance and project financing. + + We identified this bottleneck early on and proactively specialized in the highly precise surveying and digital documentation of cable routes. + + ## Digital Recording at the State of the Art + + With state-of-the-art GPS technology and self-developed digital app integrations, we ensure highly automated, seamless and absolutely legally compliant recording of all laid lines and systems. + + In addition to classic GPS staking and surveying, we create complete geodatabases for our clients for transparent project accounting and offer seamless 360° photo and video recording of the construction field. In this way, you keep full track of your underground infrastructure at all times. +
+ + + diff --git a/scripts/compare-mdx-parity.ts b/scripts/compare-mdx-parity.ts new file mode 100644 index 000000000..cbdb9643b --- /dev/null +++ b/scripts/compare-mdx-parity.ts @@ -0,0 +1,52 @@ +import fs from 'fs'; +import path from 'path'; + +const CONTENT_DIR = path.join(process.cwd(), 'content'); +const deDir = path.join(CONTENT_DIR, 'de'); +const enDir = path.join(CONTENT_DIR, 'en'); + +function extractComponents(filePath: string): string[] { + const content = fs.readFileSync(filePath, 'utf8'); + // Match any tag starting with uppercase letter, e.g. m.substring(1)); +} + +function checkParity() { + const deFiles = fs.readdirSync(deDir).filter(f => f.endsWith('.mdx')); + let hasErrors = false; + + console.log('🔍 Checking MDX Component Parity between DE and EN...'); + + deFiles.forEach(file => { + const dePath = path.join(deDir, file); + const enPath = path.join(enDir, file); + + if (!fs.existsSync(enPath)) { + console.log(`❌ Missing English file: ${file}`); + hasErrors = true; + return; + } + + const deComponents = extractComponents(dePath); + const enComponents = extractComponents(enPath); + + const deStr = deComponents.join(', '); + const enStr = enComponents.join(', '); + + if (deStr !== enStr) { + console.log(`❌ Mismatch in ${file}:`); + console.log(` DE components: [${deStr}]`); + console.log(` EN components: [${enStr}]`); + hasErrors = true; + } else { + console.log(`✅ ${file} is in perfect parity.`); + } + }); + + if (!hasErrors) { + console.log('🎉 PERFECT PARITY DETECTED! All MDX components are identical.'); + } +} + +checkParity();