Skip to content

Commit e5cb283

Browse files
committed
fix(control-ui): verify locales against shared registry
Co-authored-by: Copilot <[email protected]> Copilot-Session: 4ade23d8-abc3-418f-b143-0bf668e98582
1 parent dcec9d0 commit e5cb283

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎scripts/control-ui-i18n-verify.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { existsSync } from "node:fs";
33
import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
44
import path from "node:path";
55
import { fileURLToPath, pathToFileURL } from "node:url";
6+
import { OPENCLAW_LOCALES } from "../packages/localization-core/src/locale-registry.js";
67
import { CONTROL_UI_LOCALE_ENTRIES } from "./lib/control-ui-i18n-config.ts";
78
import { syncControlUiRawCopyBaseline } from "./lib/control-ui-i18n-raw-copy.ts";
89
import type { TranslationMap } from "./lib/control-ui-i18n-sync-plan.ts";
@@ -238,9 +239,15 @@ export async function verifyRuntimeLocaleConfig() {
238239
path.join(ROOT, "ui", "src", "i18n", "lib", "registry.ts"),
239240
"utf8",
240241
);
241-
const typesRaw = await readFile(path.join(ROOT, "ui", "src", "i18n", "lib", "types.ts"), "utf8");
242+
const configuredLocales = ["en", ...CONTROL_UI_LOCALE_ENTRIES.map((entry) => entry.locale)];
243+
const sharedUiLocales = OPENCLAW_LOCALES.filter((locale) => locale !== "sv");
244+
if (!compareStringArrays(configuredLocales, sharedUiLocales)) {
245+
throw new Error(
246+
`runtime locale config is out of sync with the shared registry: expected ${sharedUiLocales.join(", ")}, got ${configuredLocales.join(", ")}`,
247+
);
248+
}
242249
for (const entry of CONTROL_UI_LOCALE_ENTRIES) {
243-
if (!registryRaw.includes(`"${entry.locale}"`) || !typesRaw.includes(`| "${entry.locale}"`)) {
250+
if (!registryRaw.includes(`"${entry.locale}"`)) {
244251
throw new Error(`runtime locale config is missing ${entry.locale}`);
245252
}
246253
}

0 commit comments

Comments
 (0)