@traxlate/sdk
v1.0.0
Published
Official TypeScript/JavaScript client for the Traxlate translation API.
Maintainers
Readme
@traxlate/sdk
Official TypeScript/JavaScript client for the Traxlate translation API. Zero
runtime dependencies — uses global fetch (Node 18+, browsers, edge/workers).
import { TraxlateClient } from "@traxlate/sdk";
const tx = new TraxlateClient({ apiKey: process.env.TRAXLATE_KEY });
await tx.translate("Hello {name}", "en", "es"); // "Hola {name}"
await tx.translateBatch(["Save", "Cancel"], "en", "fr"); // ["…", "…"]
const { translations, cohesion } =
await tx.translateBatchDetailed(docs, "en", "de"); // cohesion = quality score per string- Locale codes: pass simple locales (
es,pt,zh-Hant); they map to the engine's FLORES-200 codes automatically (unknown values pass through). - Batching: large arrays are chunked (default 60/req) to stay under the proxy timeout.
- Cohesion:
translateBatchDetailedreturns the engine's per-string LaBSE source/translation alignment score so you can flag low-confidence segments. - Placeholder safety: handled server-side by the engine. For build-time file
or whole-site localization with client-side placeholder protection today, use
the Python SDK (
traxlate) or thelocalizeCLI.
Build: npm run build (emits dist/). Typecheck: npm run typecheck.
