import { test } from 'node:test'; import assert from 'node:assert/strict'; import { readFileSync, readdirSync } from 'node:fs'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; import { argumentShapes, createI18n, direction, fallbackChain, formatMessage, matchLocale, normalizeLocale, parseMessage, placeholders, pluralCategories, relativeParts, type Catalog, } from '../src/i18n.ts'; import { checkCatalog, checkMessageSafety, checkShape, checkSource, coverage, generateKeyTypes, type CatalogIssue, type Meta } from '../src/i18nCheck.ts'; import { createPluginI18n, pluginNamespace } from '../src/pluginI18n.ts'; import { KIT_MESSAGES } from '../src/ui.ts'; import { SHELL_MESSAGES, shellText } from '../../shell/src/messages.ts'; import { STORE_MESSAGES } from '../../shell/src/storeMessages.ts'; import { FRAME_MESSAGES } from '../../shell/src/frame/frameMessages.ts'; import { PANEL_MESSAGES } from '../../shell/src/panel/panelMessages.ts'; import { INSTALLER_MESSAGES } from '../../shell/src/installerMessages.ts'; import MENU_MESSAGES from '../../shell/src/frame/menuMessages.en.json' with { type: 'json' }; const here = dirname(fileURLToPath(import.meta.url)); test('locale tags are normalized, including X and legacy codes', () => { assert.equal(normalizeLocale('en_gb'), 'en-GB'); assert.equal(normalizeLocale('zh-cn'), 'zh-Hans'); assert.equal(normalizeLocale('zh-TW'), 'zh-Hant'); assert.equal(normalizeLocale('zh-Hant-HK'), 'zh-Hant'); assert.equal(normalizeLocale('zh'), 'zh-Hans'); assert.equal(normalizeLocale('msa'), 'ms'); assert.equal(normalizeLocale('no'), 'nb'); assert.equal(normalizeLocale('iw'), 'he'); assert.equal(normalizeLocale('ar-x-fm'), 'ar-x-fm'); assert.equal(normalizeLocale('pt-br'), 'pt-BR'); for (const bad of ['', 'x', 'english!', '