import { describe, expect, it } from 'vitest'; import { collectLocaleParityIssues, LOBBY_I18N_CATALOG, normalizeLocale, SUPPORTED_LOCALES, translateCatalogPath, } from '../shared/i18n/lobby-loader'; describe('shared lobby i18n loader parity', () => { it('keeps da/en translation parity in shared keyspace', () => { const issues = collectLocaleParityIssues(LOBBY_I18N_CATALOG, SUPPORTED_LOCALES); expect(issues).toEqual([]); }); it('normalizes browser-style locale tags to supported keyspace locales', () => { expect(normalizeLocale('da-DK')).toBe('da'); expect(normalizeLocale('da_DK')).toBe('da'); expect(normalizeLocale('en-US')).toBe('en'); expect(normalizeLocale('en_US')).toBe('en'); expect(normalizeLocale('fr-FR')).toBe('en'); }); it('resolves shared frontend ui keys with fallback-safe behavior', () => { expect( translateCatalogPath(LOBBY_I18N_CATALOG.frontend.ui as Record, 'host.start_round', 'da-DK'), ).toBe('Start runde'); expect( translateCatalogPath(LOBBY_I18N_CATALOG.frontend.ui as Record, 'app.language_label', 'en-US'), ).toBe('Language'); expect( translateCatalogPath(LOBBY_I18N_CATALOG.frontend.ui as Record, 'host.non_existing_key', 'da'), ).toBe('host.non_existing_key'); }); });