fix: normalize i18n registry lookup keys

Issue: #62
User-Visible: no
This commit is contained in:
Matysh
2026-08-28 02:55:22 +03:00
parent d0d6cf57a7
commit c755a0efc4
5 changed files with 36 additions and 19 deletions
+12
View File
@@ -5,6 +5,8 @@ import { readdirSync, readFileSync } from 'node:fs';
import {
FALLBACK_LANGUAGE_CODE,
LANGUAGE_REGISTRY,
buildLanguageLookup,
languageEntry,
languageOptions,
normalizeLanguageTag,
resolveLanguageCode,
@@ -38,6 +40,16 @@ test('i18n: registry codes and English fallback are valid', () => {
}
});
test('i18n: canonical regional codes use normalized lookup keys', () => {
const regional = { code: 'pt-BR', nativeLabel: 'Português (Brasil)', dictionary: {} };
const lookup = buildLanguageLookup([regional]);
assert.equal(lookup.get('pt-br'), regional);
assert.equal(lookup.get(normalizeLanguageTag('PT_br')), regional);
for (const entry of LANGUAGE_REGISTRY) {
assert.equal(languageEntry(entry.code.toUpperCase()), entry);
}
});
test('i18n: registry matches frontend and backend locale files', () => {
const registryCodes = LANGUAGE_REGISTRY.map(({ code }) => code).sort();
const localeCodes = (url) => readdirSync(url)