chore(i18n): remove unused config helpers (#4482)

Removes dead exports DOCS_TARGET_LOCALES and getLanguage (zero callers, Knip-reported) and adds config-adapter coverage test.

Integrated into release/v3.8.33.
This commit is contained in:
KooshaPari
2026-06-21 07:58:33 -07:00
committed by GitHub
parent 296b72d070
commit 39592420e4
2 changed files with 36 additions and 14 deletions

View File

@@ -52,17 +52,3 @@ export const LANGUAGES: readonly {
export const RTL_LOCALES: readonly Locale[] = config.rtl as readonly Locale[];
export const LOCALE_COOKIE = "NEXT_LOCALE";
// Convenience helpers --------------------------------------------------------
/** Locales that the docs translation pipeline writes to (excludes the source). */
export const DOCS_TARGET_LOCALES: readonly Locale[] = LANGUAGES.map((l) => l.code).filter(
(code) => !(config.docsExcluded ?? []).includes(code)
) as readonly Locale[];
/** Lookup by code; falls back to the default locale entry if not found. */
export function getLanguage(code: string) {
return (
LANGUAGES.find((l) => l.code === code) ?? LANGUAGES.find((l) => l.code === DEFAULT_LOCALE)!
);
}

View File

@@ -0,0 +1,36 @@
import test from "node:test";
import assert from "node:assert/strict";
import i18nConfig from "../../config/i18n.json" with { type: "json" };
import {
DEFAULT_LOCALE,
LANGUAGES,
LOCALES,
LOCALE_COOKIE,
RTL_LOCALES,
} from "../../src/i18n/config.ts";
test("i18n config adapter reflects the JSON source of truth", () => {
assert.deepEqual(
LOCALES,
i18nConfig.locales.map((locale) => locale.code)
);
assert.equal(DEFAULT_LOCALE, i18nConfig.default);
assert.deepEqual(RTL_LOCALES, i18nConfig.rtl);
assert.equal(LOCALE_COOKIE, "NEXT_LOCALE");
});
test("i18n language metadata preserves native and English names", () => {
assert.equal(LANGUAGES.length, i18nConfig.locales.length);
const english = LANGUAGES.find((language) => language.code === "en");
const englishConfig = i18nConfig.locales.find((language) => language.code === "en");
assert.deepEqual(english, {
code: "en",
label: englishConfig?.label,
name: englishConfig?.name,
native: englishConfig?.native,
english: englishConfig?.english,
flag: englishConfig?.flag,
});
});