mirror of
https://github.com/multica-ai/multica.git
synced 2026-06-17 03:38:32 +02:00
* i18n: add japanese locale * fix: spacing issues * refactor * fix(desktop): set <html lang> before paint to avoid JA Kanji font flash Switch the documentElement.lang sync from useEffect to useLayoutEffect so lang is committed before the first paint. Otherwise Japanese desktop users saw one frame of Kanji rendered with the Chinese-first fallback stack before the html[lang|="ja"] CJK override applied. Also fix the stale selector in the HTML_LANG comment (html[lang^="ja"] -> html[lang|="ja"]). Addresses review nits on MUL-2893. Co-authored-by: multica-agent <github@multica.ai> * fix(docs): tokenize the ideographic iteration mark in JA search Add U+3005 (々) to the Japanese search tokenizer character class. It sits just below the kana blocks, so words like 様々 / 日々 / 個々 previously dropped the mark and split awkwardly, hurting recall. Addresses a review nit on MUL-2893. Co-authored-by: multica-agent <github@multica.ai> * fix(i18n): restore ja locale parity after merging main Merging main brought new EN strings into agents/chat/onboarding/settings/ squads that the ja bundle (authored against an older snapshot) lacked, breaking the locales parity test. Add the Japanese translations for the new keys (workspace logo upload, agents runtime filter, chat session-history stop dialog, onboarding social_github, squad archived status) and drop the two renamed chat window keys (active_group / archived_group) that EN removed in favour of history_group. Fixes the failing @multica/views parity.test.ts on the FE CI for MUL-2893. Co-authored-by: multica-agent <github@multica.ai> --------- Co-authored-by: J <j@multica.ai> Co-authored-by: multica-agent <github@multica.ai>
102 lines
3.2 KiB
TypeScript
102 lines
3.2 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
const existingDocs = vi.hoisted(() => new Set<string>());
|
|
|
|
vi.mock("node:fs", () => ({
|
|
existsSync: vi.fn((path: string) => {
|
|
const normalized = path.replaceAll("\\", "/");
|
|
return [...existingDocs].some((suffix) => normalized.endsWith(suffix));
|
|
}),
|
|
}));
|
|
|
|
const pages = new Map<string, { url: string }>([
|
|
["en:", { url: "/" }],
|
|
["zh:", { url: "/zh" }],
|
|
["ko:", { url: "/ko" }],
|
|
["ja:", { url: "/ja" }],
|
|
["en:agents", { url: "/agents" }],
|
|
["zh:agents", { url: "/zh/agents" }],
|
|
["ko:agents", { url: "/ko/agents" }],
|
|
["ja:agents", { url: "/ja/agents" }],
|
|
]);
|
|
|
|
vi.mock("@/lib/source", () => ({
|
|
source: {
|
|
getPage: vi.fn((slugs: string[], lang: string) => {
|
|
return pages.get(`${lang}:${slugs.join("/")}`) ?? null;
|
|
}),
|
|
},
|
|
}));
|
|
|
|
beforeEach(() => {
|
|
existingDocs.clear();
|
|
existingDocs.add("index.mdx");
|
|
existingDocs.add("index.zh.mdx");
|
|
existingDocs.add("agents.mdx");
|
|
existingDocs.add("agents.zh.mdx");
|
|
});
|
|
|
|
describe("docsAlternates", () => {
|
|
it("omits Korean hreflang when no Korean MDX file exists for the page", async () => {
|
|
const { docsAlternates } = await import("./site");
|
|
|
|
expect(docsAlternates(["agents"])).toEqual({
|
|
canonical: "https://www.multica.ai/docs/agents",
|
|
languages: {
|
|
en: "https://www.multica.ai/docs/agents",
|
|
zh: "https://www.multica.ai/docs/zh/agents",
|
|
"x-default": "https://www.multica.ai/docs/agents",
|
|
},
|
|
});
|
|
});
|
|
|
|
it("omits Korean hreflang even when source.getPage returns a page for Korean", async () => {
|
|
const { docsAlternates } = await import("./site");
|
|
|
|
expect(docsAlternates(["agents"]).languages).not.toHaveProperty("ko");
|
|
});
|
|
|
|
it("includes Korean hreflang when a real *.ko.mdx page exists", async () => {
|
|
existingDocs.add("agents.ko.mdx");
|
|
const { docsAlternates } = await import("./site");
|
|
|
|
expect(docsAlternates(["agents"])).toEqual({
|
|
canonical: "https://www.multica.ai/docs/agents",
|
|
languages: {
|
|
en: "https://www.multica.ai/docs/agents",
|
|
zh: "https://www.multica.ai/docs/zh/agents",
|
|
ko: "https://www.multica.ai/docs/ko/agents",
|
|
"x-default": "https://www.multica.ai/docs/agents",
|
|
},
|
|
});
|
|
});
|
|
|
|
it("includes Japanese hreflang when a real *.ja.mdx page exists", async () => {
|
|
existingDocs.add("agents.ja.mdx");
|
|
const { docsAlternates } = await import("./site");
|
|
|
|
expect(docsAlternates(["agents"])).toEqual({
|
|
canonical: "https://www.multica.ai/docs/agents",
|
|
languages: {
|
|
en: "https://www.multica.ai/docs/agents",
|
|
zh: "https://www.multica.ai/docs/zh/agents",
|
|
ja: "https://www.multica.ai/docs/ja/agents",
|
|
"x-default": "https://www.multica.ai/docs/agents",
|
|
},
|
|
});
|
|
});
|
|
|
|
it("keeps the locale root alternates limited to real localized MDX pages", async () => {
|
|
const { docsAlternates } = await import("./site");
|
|
|
|
expect(docsAlternates([])).toEqual({
|
|
canonical: "https://www.multica.ai/docs",
|
|
languages: {
|
|
en: "https://www.multica.ai/docs",
|
|
zh: "https://www.multica.ai/docs/zh",
|
|
"x-default": "https://www.multica.ai/docs",
|
|
},
|
|
});
|
|
});
|
|
});
|