mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 17:14:33 +00:00
fix(ci): resolve i18n typing and generated-policy drift
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user