fix(ci): resolve i18n typing and generated-policy drift

This commit is contained in:
Peter Steinberger
2026-03-02 04:24:01 +00:00
parent fa9148400e
commit 1c0d36eed0
3 changed files with 22 additions and 9 deletions

View File

@@ -5,6 +5,18 @@ import {
loadLazyLocaleTranslation,
resolveNavigatorLocale,
} from "../../ui/src/i18n/lib/registry.ts";
import type { TranslationMap } from "../../ui/src/i18n/lib/types.ts";
function getNestedTranslation(map: TranslationMap | null, ...path: string[]): string | undefined {
let value: string | TranslationMap | undefined = map ?? undefined;
for (const key of path) {
if (value === undefined || typeof value === "string") {
return undefined;
}
value = value[key];
}
return typeof value === "string" ? value : undefined;
}
describe("ui i18n locale registry", () => {
it("lists supported locales", () => {
@@ -23,8 +35,8 @@ describe("ui i18n locale registry", () => {
const de = await loadLazyLocaleTranslation("de");
const zhCN = await loadLazyLocaleTranslation("zh-CN");
expect(de?.common?.health).toBe("Status");
expect(zhCN?.common?.health).toBe("健康状况");
expect(getNestedTranslation(de, "common", "health")).toBe("Status");
expect(getNestedTranslation(zhCN, "common", "health")).toBe("健康状况");
expect(await loadLazyLocaleTranslation("en")).toBeNull();
});
});