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.
41 lines
1.6 KiB
JavaScript
41 lines
1.6 KiB
JavaScript
// tests/e2e-docs/fixtures/seed-de-locale.mjs
|
|
import { rm } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { createDocsAdapter } from "../../../scripts/i18n/adapters/docs-md.mjs";
|
|
|
|
const DOCS = fileURLToPath(new URL("../../../apps/docs", import.meta.url));
|
|
// The e2e asserts against these; only they get the [DE] heading prefix. Every
|
|
// other file is still written under /de/ (English body) so the seeded German
|
|
// tree has no dead internal links and VitePress builds it cleanly.
|
|
const PICK = new Set(["index.md", "guide/getting-started.md", "guide/configuration.md"]);
|
|
|
|
async function main() {
|
|
await rm(join(DOCS, "de"), { recursive: true, force: true });
|
|
const adapter = createDocsAdapter({ root: DOCS });
|
|
const units = await adapter.extract();
|
|
const entries = new Map();
|
|
for (const u of units) {
|
|
// Deterministic pseudo-translation: PICK pages get a [DE] ATX-heading prefix;
|
|
// the rest keep their English body. Masked tokens, anchors, frontmatter, and
|
|
// links stay intact so the write path is exercised exactly as in production.
|
|
const text = PICK.has(u.id)
|
|
? u.sourceText.replace(/^(#{1,6} )(.+)$/gm, (_m, h, rest) => `${h}[DE] ${rest}`)
|
|
: u.sourceText;
|
|
entries.set(u.id, {
|
|
text,
|
|
sourceHash: "seedhash0001",
|
|
provenance: "machine",
|
|
outputHash: "0".repeat(12),
|
|
stale: false,
|
|
});
|
|
}
|
|
await adapter.write("de", entries);
|
|
console.log(`Seeded ${entries.size} German docs pages (${PICK.size} with [DE] prefix).`);
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error(err);
|
|
process.exit(1);
|
|
});
|