Compare commits

..
2 Commits
Author SHA1 Message Date
Do SikiandClaude Opus 5.5 af45b23750 sync: update Plane issues + TODO [MITHOME-115 language switcher]
CI Pipeline with Test Management / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
CI Pipeline with Test Management / 🐳 Docker Integration Tests (push) Canceled after 0s
CI Pipeline with Test Management / 🏗️ Build Docker Image (push) Canceled after 0s
CI Pipeline with Test Management / 📊 Generate Test Summary (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 📊 Analyze Test Coverage (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🔄 Sync with Linear (push) Canceled after 0s
Test Reporting & Gherkin Analysis / ⚡ Performance Monitoring (push) Canceled after 0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 12:22:27 +02:00
Do SikiandClaude Opus 5.5 2bb9f122d5 feat(web): HU | EN language switcher in the header (MITHOME-115)
A compact "HU | EN" switcher next to the theme toggle (desktop) and the
menu button (mobile). Each link opens the current page in the other
language with its translated slug (/hu/szolgaltatasok <-> /en/services),
unknown pages fall back to the language's home. English is always
offered (user decision), even before a page's English is approved.

Links carry lang/hrefLang, the active one aria-current, and the group a
localized accessible name. No flags: a flag marks a country, not a
language. Unit and component tests plus staging smoke SMOKE-08.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 12:22:11 +02:00
10 changed files with 186 additions and 5 deletions
+2 -1
View File
@@ -141,7 +141,7 @@ Cél: a weboldal magyar (alapértelmezett, prefix nélkül, pl. `/rolunk`) és a
| MITHOME-112 | LegalPages collection retrofit: localized mezők | ✅ |
| MITHOME-113 | AI-draft angol tartalom + migrációs script bővítése (en locale seed) | ✅ |
| MITHOME-114 | Next.js /hu/ + /en/ szimmetrikus prefix routing (egy menetben MITHOME-91-gyel) | ✅ |
| MITHOME-115 | Nyelvválasztó UI komponens (Header) | 📋 |
| MITHOME-115 | Nyelvválasztó UI komponens (Header) | ✅ |
| MITHOME-116 | SEO: hreflang tagek és kétnyelvű sitemap | 📋 |
### EPIC: Hermes Agent — kapcsolatfelvételi triázs pilot (MITHOME-99) — **LEZÁRVA, duplikátum**
@@ -212,6 +212,7 @@ docker-compose -f docker-compose.dev.yml down
---
## Frissítési Napló
- **2026-09-29**: MITHOME-115 (nyelvválasztó) kész (main, staging deploy még nem történt). „HU | EN” szöveges kapcsoló a fejlécben (asztalon a témaváltó, mobilon a menügomb mellett), megőrzi az aktuális oldalt a fordított sluggal. Felhasználói döntés: az EN mindig látszik, jóváhagyás előtt az angol oldal a MITHOME-113 kapu miatt magyar tartalmat mutat. `lang`/`hrefLang`/`aria-current`, nyelvenkénti csoportcímke; új staging smoke: SMOKE-08. A `jest-axe` nincs telepítve (új függőség lenne), az a11y-attribútumokat explicit tesztek fedik.
- **2026-09-29**: MITHOME-126 (bug: `write after end` a build alatt) kész. Gyökérok: a `logger.ts` SIGTERM/SIGINT kezelője minden modul-kiértékeléskor újra regisztrálódott, és ha egy build worker mindkét jelet megkapta, a második hívás a már lezárt (`logger.end()`) Winston streamre logolt. A `logger.writableEnded` guardként nem működik, mert a winston Logger `readable-stream@3` Transform, amiben ez a property nincs. Javítás: saját `hasShutdownStarted` flag, a kezelők processzenként egyszer, `process.once`-szal regisztrálódnak. Felfedező + megőrző tesztek a `logger.test.ts`-ben (fix-bug workflow); `npm test`, lint, `tsc --noEmit` zöld, 3 egymás utáni buildben nincs `write after end`.
- **2026-09-29**: MITHOME-112 + MITHOME-113 kiadva stagingre (`b3331d5`). Mentés deploy előtt: `~/backups/mozdit-staging-20260929-120203-pre-mithome-112-113.archive`. Induláskor lefutott a legal-pages lokalizáció (72 érték) és az angol AI-draft import (324 érték, 0 egyezés nélküli). 8/8 staging smoke zöld; a `/hu` változatlan, az `/en` jóváhagyásig magyar. Az adminban minden oldal „AI-draft, átnézésre vár” állapotban van.
- **2026-09-29**: MITHOME-112 + MITHOME-113 kész (main, staging deploy még nem történt), OpenSpec: `openspec/changes/english-content-mithome-112-113`. A LegalPages lokalizált (migrációval). Minden Global és jogi oldal „Angol fordítás állapota” mezőt kapott (Nincs / AI-draft / Jóváhagyva); a publikus `/en` csak jóváhagyás után mutat angolt. Az AI-draft angol tartalom (179 szöveg az élő staging tartalomból, `src/content/translations/en.json`) migrációval kerül be, csak üres angol mezőbe és pontos magyar egyezésnél. A jogi oldalakon „Jogi validáció” blokk: másolható validációs prompt és a kézzel futtatott modellek visszaírt válaszai; a jóváhagyáshoz legalább két különböző modell el nem utasító validálása kell (felhasználói döntés: a validálást kézzel végzik, bármely szolgáltató modelljével). Staging-másolaton ellenőrizve (324 angol érték, 0 egyezés nélküli; a `/hu` szövegre azonos). Élő teszt közben talált és javított hiba: a vágólap-másolás tartalék lánccal. Mellékmegfigyelés: `npm run build` alatt a logger leállítási kezelője `write after end` hibát ír (`logger.ts`, MITHOME-17), a build ettől sikeres.
+10
View File
@@ -75,6 +75,16 @@ test('SMOKE-07: external links on the homepage open in a new tab', async ({ page
}
})
// MITHOME-115: the language switcher keeps the current page (translated slug).
test('SMOKE-08: language switcher opens the same page in the other language', async ({ page }) => {
await page.goto('/hu/szolgaltatasok')
const english = page.getByRole('group', { name: 'Nyelv kiválasztása' }).first().getByRole('link', { name: 'English' })
await expect(english).toHaveAttribute('href', '/en/services')
await english.click()
await expect(page).toHaveURL(/\/en\/services$/)
await expect(page.getByRole('group', { name: 'Choose language' }).first().getByRole('link', { name: 'Magyar' })).toHaveAttribute('href', '/hu/szolgaltatasok')
})
test('SMOKE-05: empty contact form is blocked client-side without API submission', async ({ page }) => {
let contactPostCount = 0
page.on('request', request => {
+2 -1
View File
@@ -3,7 +3,7 @@ import Header from '../../../components/Header'
import Footer from '../../../components/Footer'
import { isLocale, localePath, type Locale } from '@/lib/i18n'
import { getCommonContent, getHomeContent } from '@/lib/payload-content'
import { siteConfig, getMainNavigation, getFooterNavigation, getFooterLegalLinks, getSiteDescription } from '@/config/site'
import { siteConfig, getMainNavigation, getFooterNavigation, getFooterLegalLinks, getSiteDescription, getLanguageSwitcherLabel } from '@/config/site'
// WHY force-dynamic (MITHOME-97): ezek az oldalak a Payload Local API-t hívják
// (élő MongoDB-olvasás). generateStaticParams + SSG mellett a build időben
@@ -43,6 +43,7 @@ export default async function LocaleLayout({
nav={getMainNavigation(locale)}
homeHref={localePath(locale)}
a11y={common.a11y}
languageLabel={getLanguageSwitcherLabel(locale)}
/>
<main className="flex-1">
{children}
+1
View File
@@ -19,6 +19,7 @@ const headerProps = {
nav: getMainNavigation('hu'),
homeHref: '/hu',
a11y: common.a11y,
languageLabel: 'Nyelv kiválasztása',
}
describe('Header', () => {
+8 -3
View File
@@ -7,14 +7,17 @@ import Link from 'next/link'
import Image from 'next/image'
import type { NavigationItem } from '@/types/site'
import { externalLinkProps, isExternalHref } from '@/lib/external-link'
import { LanguageSwitcher } from './LanguageSwitcher'
type HeaderProps = {
nav: NavigationItem[]
homeHref: string
a11y: { openMenu: string; closeMenu: string }
/** MITHOME-115: accessible name of the language switcher group. */
languageLabel: string
}
export default function Header({ nav, homeHref, a11y }: HeaderProps) {
export default function Header({ nav, homeHref, a11y, languageLabel }: HeaderProps) {
const [isMenuOpen, setIsMenuOpen] = useState(false)
const [isScrolled, setIsScrolled] = useState(false)
@@ -102,14 +105,16 @@ export default function Header({ nav, homeHref, a11y }: HeaderProps) {
</a>
))}
{/* Theme Toggle */}
<div className="ml-2 pl-2" style={{ borderLeft: `1px solid var(--color-border)` }}>
{/* Language switcher + Theme Toggle */}
<div className="ml-2 pl-2 flex items-center gap-1" style={{ borderLeft: `1px solid var(--color-border)` }}>
<LanguageSwitcher label={languageLabel} />
<ThemeToggle />
</div>
</div>
{/* Mobile menu button */}
<div className="md:hidden flex items-center gap-2">
<LanguageSwitcher label={languageLabel} />
<ThemeToggle />
<button
type="button"
@@ -0,0 +1,39 @@
import { render, screen } from '@testing-library/react'
import '@testing-library/jest-dom'
import { usePathname } from 'next/navigation'
import { LanguageSwitcher } from './LanguageSwitcher'
jest.mock('next/navigation', () => ({ usePathname: jest.fn() }))
const mockPath = (path: string) => (usePathname as jest.Mock).mockReturnValue(path)
describe('LanguageSwitcher (MITHOME-115)', () => {
it('should link both languages to the same page with translated slugs', () => {
mockPath('/hu/szolgaltatasok')
render(<LanguageSwitcher label="Nyelv kiválasztása" />)
expect(screen.getByRole('link', { name: 'Magyar' })).toHaveAttribute('href', '/hu/szolgaltatasok')
expect(screen.getByRole('link', { name: 'English' })).toHaveAttribute('href', '/en/services')
})
it('should mark the current language and label the group', () => {
mockPath('/en/about')
render(<LanguageSwitcher label="Choose language" />)
expect(screen.getByRole('group', { name: 'Choose language' })).toBeInTheDocument()
expect(screen.getByRole('link', { name: 'English' })).toHaveAttribute('aria-current', 'true')
expect(screen.getByRole('link', { name: 'Magyar' })).not.toHaveAttribute('aria-current')
})
it('should declare the language of each link for assistive technology', () => {
mockPath('/hu')
render(<LanguageSwitcher label="Nyelv kiválasztása" />)
const english = screen.getByRole('link', { name: 'English' })
expect(english).toHaveAttribute('lang', 'en')
expect(english).toHaveAttribute('hrefLang', 'en')
expect(english).toHaveTextContent('EN')
})
it('should always offer English, even from an unknown page', () => {
mockPath('/hu/nincs-ilyen')
render(<LanguageSwitcher label="Nyelv kiválasztása" />)
expect(screen.getByRole('link', { name: 'English' })).toHaveAttribute('href', '/en')
})
})
+48
View File
@@ -0,0 +1,48 @@
'use client'
import { Fragment } from 'react'
import Link from 'next/link'
import { usePathname } from 'next/navigation'
import { LOCALE_NAMES, languageLinks } from '@/lib/i18n'
/**
* MITHOME-115: compact "HU | EN" switcher. Each link keeps the current page
* in the other language (translated slug, src/lib/i18n.ts languageLinks).
*
* DECISION (user): English is always offered, even before a page's English
* translation is approved — the page then shows Hungarian text (MITHOME-113
* gate). No flags: a flag marks a country, not a language.
* WHY `lang`/`hrefLang` on the links: screen readers pronounce "English"
* correctly on a Hungarian page (WCAG 3.1.2).
*/
export function LanguageSwitcher({ label }: { label: string }) {
const links = languageLinks(usePathname() ?? '/')
return (
<div role="group" aria-label={label} className="flex items-center text-sm">
{links.map((link, index) => (
<Fragment key={link.locale}>
{index > 0 && (
<span aria-hidden="true" style={{ color: 'var(--color-border)' }}>
|
</span>
)}
<Link
href={link.href}
hrefLang={link.locale}
lang={link.locale}
aria-label={LOCALE_NAMES[link.locale].name}
aria-current={link.isActive ? 'true' : undefined}
className="px-1.5 py-1 rounded transition-colors duration-200 hover-scale"
style={{
color: link.isActive ? 'var(--color-primary-600)' : 'var(--color-foreground-muted)',
fontWeight: link.isActive ? 700 : 500,
}}
>
{LOCALE_NAMES[link.locale].code}
</Link>
</Fragment>
))}
</div>
)
}
+10
View File
@@ -42,6 +42,16 @@ const NAV_LABELS: Record<Locale, { home: string; about: string; services: string
en: { home: 'Home', about: 'About', services: 'Services', contact: 'Contact', privacy: 'Privacy Policy', terms: 'Terms of Service' },
}
/** MITHOME-115: a nyelvválasztó csoportjának akadálymentes címkéje. */
const LANGUAGE_SWITCHER_LABELS: Record<Locale, string> = {
hu: 'Nyelv kiválasztása',
en: 'Choose language',
}
export function getLanguageSwitcherLabel(locale: Locale): string {
return LANGUAGE_SWITCHER_LABELS[locale]
}
export function getMainNavigation(locale: Locale): NavigationItem[] {
const t = NAV_LABELS[locale]
return [
+34
View File
@@ -0,0 +1,34 @@
import { languageLinks, parseLocalePath } from './i18n'
describe('parseLocalePath (MITHOME-115)', () => {
it.each([
['/hu/rolunk', { locale: 'hu', slug: 'rolunk' }],
['/en', { locale: 'en', slug: undefined }],
['/en/services/', { locale: 'en', slug: 'services' }],
['/', { locale: 'hu' }],
['/admin', { locale: 'hu' }],
])('should parse %s', (path, expected) => {
expect(parseLocalePath(path)).toEqual(expected)
})
})
describe('languageLinks (MITHOME-115)', () => {
it('should keep the current page with its translated slug', () => {
expect(languageLinks('/hu/szolgaltatasok')).toEqual([
{ locale: 'hu', href: '/hu/szolgaltatasok', isActive: true },
{ locale: 'en', href: '/en/services', isActive: false },
])
expect(languageLinks('/en/privacy-policy').map((l) => l.href)).toEqual(['/hu/adatvedelem', '/en/privacy-policy'])
})
it('should link the home pages from a home page', () => {
expect(languageLinks('/en').map((l) => [l.href, l.isActive])).toEqual([
['/hu', false],
['/en', true],
])
})
it('should fall back to the other language home for an unknown page', () => {
expect(languageLinks('/hu/nincs-ilyen').map((l) => l.href)).toEqual(['/hu', '/en'])
})
})
+32
View File
@@ -50,3 +50,35 @@ export function switchLocalePath(currentLocale: Locale, targetLocale: Locale, sl
const key = resolvePageKey(currentLocale, slug)
return localePath(targetLocale, key)
}
/**
* MITHOME-115: nyelvnevek a nyelvválasztóhoz. WHY statikus és nem Payload-
* tartalom: a nyelv kódja és saját nyelvű neve (endonim) nem fordítandó
* szöveg — ugyanaz minden nyelvű oldalon.
*/
export const LOCALE_NAMES: Record<Locale, { code: string; name: string }> = {
hu: { code: 'HU', name: 'Magyar' },
en: { code: 'EN', name: 'English' },
}
/** A böngésző útvonalából a nyelv és a szlög (`/hu/rolunk` → hu, rolunk). */
export function parseLocalePath(pathname: string): { locale: Locale; slug?: string } {
const [first, second] = pathname.split('/').filter(Boolean)
return first && isLocale(first) ? { locale: first, slug: second } : { locale: DEFAULT_LOCALE }
}
export type LanguageLink = { locale: Locale; href: string; isActive: boolean }
/**
* MITHOME-115: a nyelvválasztó linkjei — minden nyelvre ugyanaz az oldal a
* lefordított szlöggel (/hu/szolgaltatasok ↔ /en/services); ismeretlen
* oldalnál az adott nyelv főoldala.
*/
export function languageLinks(pathname: string): LanguageLink[] {
const { locale, slug } = parseLocalePath(pathname)
return LOCALES.map((target) => ({
locale: target,
href: switchLocalePath(locale, target, slug),
isActive: target === locale,
}))
}