Files
SnapOtter/scripts/i18n/lib/glossary.mjs
T
SnapOtterandGitHub 00b651c9f8 feat(i18n): 21-language pipeline, landing/docs/API wiring, landing+API translations
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.
2026-07-11 13:01:55 +08:00

62 lines
1.6 KiB
JavaScript

// scripts/i18n/lib/glossary.mjs
import { SUPPORTED_LOCALES } from "../../../packages/shared/src/i18n/index.ts";
/** Terms that must stay verbatim in every language. */
export const DO_NOT_TRANSLATE = [
"SnapOtter",
"API",
"REST",
"JSON",
"YAML",
"URL",
"HTTP",
"JPEG",
"PNG",
"WebP",
"AVIF",
"HEIC",
"GIF",
"SVG",
"EXIF",
"PDF",
"FFmpeg",
"Docker",
"Compose",
"Postgres",
"Redis",
"OIDC",
"SSO",
"SAML",
"SCIM",
];
/**
* @param {string} locale
* @returns {string} the English display name of the locale
*/
function localeName(locale) {
const entry = SUPPORTED_LOCALES.find((l) => l.code === locale);
if (!entry) throw new Error(`Unknown locale: ${locale}`);
return entry.name;
}
/**
* System prompt for translating one batch into `locale`.
* @param {string} locale
* @returns {string}
*/
export function buildSystemPrompt(locale) {
const name = localeName(locale);
return [
`You are a professional software-localization translator. Translate the user's content into ${name}.`,
"",
"Rules:",
`- Translate prose only. Preserve all markdown structure, whitespace, and line breaks exactly.`,
`- Never translate, reorder, or remove any ⸤I18N…⸥ marker. Copy each one verbatim in place.`,
`- Do not translate these terms; keep them exactly as written: ${DO_NOT_TRANSLATE.join(", ")}.`,
`- Keep code, URLs, file paths, and CLI flags unchanged.`,
`- Preserve the meaning and tone. Do not add notes, explanations, or extra text.`,
`- Output only the translation. No preamble, no closing remarks.`,
].join("\n");
}