Files
TREK/shared/src/i18n/languages.spec.ts
T
Maurice 8f02337d45 fix(i18n): hand Intl and the document the real language tag for br and gr
TREK's codes 'br' (Brazilian Portuguese) and 'gr' (Greek) went straight
into <html lang> and into ten Intl calls. 'br' is Breton, so Brazilian
users got Breton month names and screen readers announced the page as
Breton; 'gr' is no language at all, so Greek users got the default
locale. getIntlLanguage maps both, and every one of those sites goes
through it.
2026-10-07 16:34:59 +02:00

24 lines
866 B
TypeScript

import { getIntlLanguage, SUPPORTED_LANGUAGES } from './languages';
import { describe, expect, it } from 'vitest';
describe('getIntlLanguage', () => {
it('maps the two codes that are not the BCP-47 tag of their language', () => {
expect(getIntlLanguage('br')).toBe('pt-BR');
expect(getIntlLanguage('gr')).toBe('el');
});
it('passes every other supported code through and falls back to English', () => {
expect(getIntlLanguage('de')).toBe('de');
expect(getIntlLanguage('zh-TW')).toBe('zh-TW');
expect(getIntlLanguage('xx')).toBe('en');
});
it('gives Intl a tag it formats in the right language for every supported code', () => {
for (const { value, locale } of SUPPORTED_LANGUAGES) {
const primary = locale.split('-')[0];
expect(new Intl.Locale(getIntlLanguage(value)).language, value).toBe(primary);
}
});
});