mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
Shared Claude Code translation pipeline (scripts/i18n, no API key) plus Astro/VitePress/Scalar i18n wiring. Landing and API reference translated into all 20 languages; docs i18n wiring + English source anchors. The translated docs markdown (apps/docs/<locale>/**, 3,620 files) follows in a companion PR because it exceeds GitHub's per-PR CI file limit.
22 lines
971 B
TypeScript
22 lines
971 B
TypeScript
// tests/unit/scripts/i18n/claude.test.ts
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import { makeTranslator } from "../../../../scripts/i18n/lib/claude.mjs";
|
|
|
|
describe("makeTranslator", () => {
|
|
it("masks input, sends one call per unit, restores tokens, returns id->text", async () => {
|
|
const send = vi.fn(async ({ text }) => `DE(${text})`);
|
|
const translate = makeTranslator({ send });
|
|
const units = [
|
|
{ id: "a", sourceText: "Hello `code`", kind: "markdown" },
|
|
{ id: "b", sourceText: "See {n} files", kind: "markdown" },
|
|
];
|
|
const out = await translate(units, "de");
|
|
// Tokens were restored, so the code span and placeholder survive verbatim.
|
|
expect(out.get("a")).toContain("`code`");
|
|
expect(out.get("b")).toContain("{n}");
|
|
expect(send).toHaveBeenCalledTimes(2);
|
|
// The masked text sent to the model must NOT contain the raw code span.
|
|
expect(send.mock.calls[0][0].text).not.toContain("`code`");
|
|
});
|
|
});
|