Files
SnapOtter/apps/docs/.vitepress/i18n/ui.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

56 lines
1.8 KiB
JavaScript

// apps/docs/.vitepress/i18n/ui.mjs
import { SUPPORTED_LOCALES } from "../../../../packages/shared/src/i18n/index.ts";
// Source strings (English). Other locales override keys as translations land;
// missing keys fall back to English via t().
const EN = {
// DocsHome.vue
"home.title": "SnapOtter Documentation",
"home.copy": "Copy",
"home.copied": "Copied!",
"home.selfHosting": "Self-hosting",
"home.enterprise": "Enterprise",
"home.startSelfHosting": "Start self-hosting →",
"home.evaluate": "See enterprise features →",
"home.modalities": "200+ tools across 5 modalities",
"home.browseByType": "browse the full reference by type",
// FundButton.vue
"fund.label": "Fund Development",
// GitHubStars.vue
"github.star": "Star",
// Machine-translation banner
"banner.text": "This page was machine-translated. Spotted a mistake?",
"banner.cta": "Help improve it.",
// not-found (Layout.vue)
"notFound.heading": "Hello from the otter side!",
"notFound.text": "This page swam away. Let's get you back on track.",
"notFound.link": "Back to docs",
};
// Per-locale overrides. Generated/refined by the pipeline in Plan 05; ships with
// English only, so t() returns English for every non-en locale until then.
/** @type {Record<string, Record<string, string>>} */
const OVERRIDES = {};
/**
* @param {string} locale
* @param {string} key
* @returns {string}
*/
export function t(locale, key) {
return OVERRIDES[locale]?.[key] ?? EN[key] ?? key;
}
/**
* Normalize a VitePress lang to a catalog locale key (en for English variants).
* @param {string} lang
* @returns {string}
*/
export function normalizeLocale(lang) {
const code = (lang || "en").trim();
if (code === "en" || code.startsWith("en-")) return "en";
return SUPPORTED_LOCALES.some((l) => l.code === code) ? code : "en";
}
export { SUPPORTED_LOCALES };