惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
G
Google Developers Blog
博客园 - 司徒正美
J
Java Code Geeks
aimingoo的专栏
aimingoo的专栏
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
T
The Blog of Author Tim Ferriss
D
Docker
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
腾讯CDC
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Check Point Blog
M
MIT News - Artificial intelligence
Jina AI
Jina AI
I
InfoQ
雷峰网
雷峰网
The Cloudflare Blog
美团技术团队
Engineering at Meta
Engineering at Meta

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
test(i18n): make registry test sparse-safe · openclaw/ope...
vincentkoc · 2026-04-26 · via Recent Commits to openclaw:main

@@ -1,14 +1,27 @@

1-

import { describe, expect, it } from "vitest";

2-

import {

3-

DEFAULT_LOCALE,

4-

SUPPORTED_LOCALES,

5-

loadLazyLocaleTranslation,

6-

resolveNavigatorLocale,

7-

} from "../../ui/src/i18n/lib/registry.ts";

8-

import type { TranslationMap } from "../../ui/src/i18n/lib/types.ts";

1+

import fs from "node:fs";

2+

import { fileURLToPath } from "node:url";

3+

import { beforeAll, describe, expect, it } from "vitest";

9410-

function getNestedTranslation(map: TranslationMap | null, ...path: string[]): string | undefined {

11-

let value: string | TranslationMap | undefined = map ?? undefined;

5+

type TranslationTree = {

6+

readonly [key: string]: string | TranslationTree | undefined;

7+

};

8+9+

type LocaleRegistry = {

10+

DEFAULT_LOCALE: string;

11+

SUPPORTED_LOCALES: readonly string[];

12+

loadLazyLocaleTranslation(locale: string): Promise<TranslationTree | null>;

13+

resolveNavigatorLocale(locale: string): string;

14+

};

15+16+

const registryModuleUrl = new URL("../../ui/src/i18n/lib/registry.ts", import.meta.url);

17+

const describeWhenUiI18nPresent = fs.existsSync(fileURLToPath(registryModuleUrl))

18+

? describe

19+

: describe.skip;

20+21+

let registry: LocaleRegistry;

22+23+

function getNestedTranslation(map: TranslationTree | null, ...path: string[]): string | undefined {

24+

let value: string | TranslationTree | undefined = map ?? undefined;

1225

for (const key of path) {

1326

if (value === undefined || typeof value === "string") {

1427

return undefined;

@@ -18,9 +31,13 @@ function getNestedTranslation(map: TranslationMap | null, ...path: string[]): st

1831

return typeof value === "string" ? value : undefined;

1932

}

203321-

describe("ui i18n locale registry", () => {

34+

describeWhenUiI18nPresent("ui i18n locale registry", () => {

35+

beforeAll(async () => {

36+

registry = (await import("../../ui/src/i18n/lib/registry.ts")) as LocaleRegistry;

37+

});

38+2239

it("lists supported locales", () => {

23-

expect(SUPPORTED_LOCALES).toEqual([

40+

expect(registry.SUPPORTED_LOCALES).toEqual([

2441

"en",

2542

"zh-CN",

2643

"zh-TW",

@@ -36,39 +53,39 @@ describe("ui i18n locale registry", () => {

3653

"pl",

3754

"th",

3855

]);

39-

expect(DEFAULT_LOCALE).toBe("en");

56+

expect(registry.DEFAULT_LOCALE).toBe("en");

4057

});

41584259

it("resolves browser locale fallbacks", () => {

43-

expect(resolveNavigatorLocale("de-DE")).toBe("de");

44-

expect(resolveNavigatorLocale("es-ES")).toBe("es");

45-

expect(resolveNavigatorLocale("es-MX")).toBe("es");

46-

expect(resolveNavigatorLocale("pt-PT")).toBe("pt-BR");

47-

expect(resolveNavigatorLocale("zh-HK")).toBe("zh-TW");

48-

expect(resolveNavigatorLocale("en-US")).toBe("en");

49-

expect(resolveNavigatorLocale("ja-JP")).toBe("ja-JP");

50-

expect(resolveNavigatorLocale("ko-KR")).toBe("ko");

51-

expect(resolveNavigatorLocale("fr-CA")).toBe("fr");

52-

expect(resolveNavigatorLocale("tr-TR")).toBe("tr");

53-

expect(resolveNavigatorLocale("uk-UA")).toBe("uk");

54-

expect(resolveNavigatorLocale("id-ID")).toBe("id");

55-

expect(resolveNavigatorLocale("pl-PL")).toBe("pl");

56-

expect(resolveNavigatorLocale("th-TH")).toBe("th");

60+

expect(registry.resolveNavigatorLocale("de-DE")).toBe("de");

61+

expect(registry.resolveNavigatorLocale("es-ES")).toBe("es");

62+

expect(registry.resolveNavigatorLocale("es-MX")).toBe("es");

63+

expect(registry.resolveNavigatorLocale("pt-PT")).toBe("pt-BR");

64+

expect(registry.resolveNavigatorLocale("zh-HK")).toBe("zh-TW");

65+

expect(registry.resolveNavigatorLocale("en-US")).toBe("en");

66+

expect(registry.resolveNavigatorLocale("ja-JP")).toBe("ja-JP");

67+

expect(registry.resolveNavigatorLocale("ko-KR")).toBe("ko");

68+

expect(registry.resolveNavigatorLocale("fr-CA")).toBe("fr");

69+

expect(registry.resolveNavigatorLocale("tr-TR")).toBe("tr");

70+

expect(registry.resolveNavigatorLocale("uk-UA")).toBe("uk");

71+

expect(registry.resolveNavigatorLocale("id-ID")).toBe("id");

72+

expect(registry.resolveNavigatorLocale("pl-PL")).toBe("pl");

73+

expect(registry.resolveNavigatorLocale("th-TH")).toBe("th");

5774

});

58755976

it("loads lazy locale translations from the registry", async () => {

60-

const de = await loadLazyLocaleTranslation("de");

61-

const es = await loadLazyLocaleTranslation("es");

62-

const ptBR = await loadLazyLocaleTranslation("pt-BR");

63-

const zhCN = await loadLazyLocaleTranslation("zh-CN");

64-

const th = await loadLazyLocaleTranslation("th");

77+

const de = await registry.loadLazyLocaleTranslation("de");

78+

const es = await registry.loadLazyLocaleTranslation("es");

79+

const ptBR = await registry.loadLazyLocaleTranslation("pt-BR");

80+

const zhCN = await registry.loadLazyLocaleTranslation("zh-CN");

81+

const th = await registry.loadLazyLocaleTranslation("th");

65826683

expect(getNestedTranslation(de, "common", "health")).toBe("Status");

6784

expect(getNestedTranslation(es, "common", "health")).toBe("Estado");

6885

expect(getNestedTranslation(es, "languages", "de")).toBe("Deutsch (Alemán)");

6986

expect(getNestedTranslation(ptBR, "languages", "es")).toBe("Español (Espanhol)");

7087

expect(getNestedTranslation(zhCN, "common", "health")).toBe("\u5065\u5eb7\u72b6\u51b5");

7188

expect(getNestedTranslation(th, "languages", "en")).toBeTruthy();

72-

expect(await loadLazyLocaleTranslation("en")).toBeNull();

89+

expect(await registry.loadLazyLocaleTranslation("en")).toBeNull();

7390

});

7491

});