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>
This commit is contained in:
Do Siki
2026-09-29 12:22:11 +02:00
co-authored by Claude Opus 5.5
parent 8687ae28a2
commit 2bb9f122d5
9 changed files with 184 additions and 4 deletions
+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'])
})
})