Files
multica/apps/docs/lib/site.test.ts
Bohan Jiang 9fe7c935a9 MUL-2817: docs(i18n): add Korean (ko) documentation translation (#3521)
* docs(i18n): translate documentation corpus to Korean

Add Korean (.ko.mdx) translations for all 32 navigable docs pages plus
meta.ko.json navigation, mirroring the English source. Product terms
(Issue→이슈, Agent→에이전트, Squad→스쿼드, Runtime→런타임, Skill→스킬,
Workspace→워크스페이스, etc.) follow the in-app Korean locale at
packages/views/locales/ko/. Roles (owner/admin/member) and issue status
enums stay lowercase English per the conventions glossary.

MUL-2817

Co-authored-by: multica-agent <github@multica.ai>

* feat(docs): serve Korean docs content, remove English-fallback stopgap

Now that the *.ko.mdx corpus exists, drop the temporary docsContentLang
ko→en shim and the static-params fallback-synthesis loop so /docs/ko/*
renders real Korean content. Korean is now a first-class locale whose
params come straight from source.generateParams(). Also align the docs
home hero copy (agent→에이전트) with the app and the translated body.

MUL-2817

Co-authored-by: multica-agent <github@multica.ai>

* docs(i18n): align residual Korean UI/product terms with the app

Address review: sweep the .ko.mdx corpus for product/UI terms left in
English and match the in-app Korean locale.

- skills page title Skills → 스킬
- UI nav paths localized: Settings → 설정, Runtimes → 런타임, Agents →
  에이전트, Projects → 프로젝트, Squads/New squad → 스쿼드/새 스쿼드,
  Usage → 사용량, Personal Access Tokens → API 토큰, Provider → 제공자,
  and the agent-create form labels (Name/Provider/Model/Instructions →
  이름/제공자/모델/지침)
- see-also links Issues/Workspaces/Environment variables and
  'Providers Matrix' → Korean
- kept as literals (verified): code blocks, the conventions i18n glossary
  data, 'Anthropic Agent Skills' (standard name), the Squad Operating
  Protocol/Roster/Instructions prompt-block names, the literal 'Project
  Context' prompt section, and Xcode's Settings path
- add a docsAlternates test asserting ko hreflang is emitted when a real
  *.ko.mdx page exists

MUL-2817

Co-authored-by: multica-agent <github@multica.ai>

---------

Co-authored-by: J <j@multica.ai>
Co-authored-by: multica-agent <github@multica.ai>
2026-05-29 16:51:13 +08:00

85 lines
2.6 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" }],
["en:agents", { url: "/agents" }],
["zh:agents", { url: "/zh/agents" }],
["ko:agents", { url: "/ko/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("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",
},
});
});
});