@withmateza/website
v0.1.3
Published
Website translation helpers for Mateza-powered sites.
Downloads
499
Readme
@withmateza/website
Website translation helpers for Mateza-powered sites.
Use this package when you need to translate and persist DOM content for a website or landing page. It builds on the SDK and adds bundle creation, parsing, and a browser controller for live page translation.
Install
npm install @withmateza/website
pnpm add @withmateza/websiteThis package is published to the public npm registry and depends on @withmateza/sdk.
Quick Start
import { createWebsiteTranslator } from "@withmateza/website";
const translator = createWebsiteTranslator({
baseUrl: "https://api.mateza.rw",
clientKey: process.env.NEXT_PUBLIC_MATEZA_CLIENT_KEY,
projectId: "proj_123",
sourceLang: "en",
targetLang: "rw",
root: document.body,
});
const summary = await translator.refresh();
console.log(summary.textNodes, summary.attributes);If you need a portable translation snapshot, call snapshotBundle() and store the returned bundle as JSON. You can later validate or restore it with parseWebsiteTranslationBundle() and applyBundle().
API Overview
Exported entry points:
createWebsiteTranslatorcreateWebsiteTranslationBundleparseWebsiteTranslationBundleparseWebsiteBundleResponse- the public types exported from
src/index.ts
Typical use cases:
- Live website translation against a DOM root
- Generating a portable translation bundle for storage or sync
- Validating a bundle response returned from the API
Auth and Config
- Set
baseUrlto the Mateza API host. - Use
clientKeyin browser contexts. - Use
apiKeyonly in trusted server-side code. - Provide
projectId,sourceLang, andtargetLangbefore callingrefresh(). - Pass
rootwhen translating a subtree instead of the full document body.
Common Mistakes
- Using a server API key in browser code.
- Forgetting to set
projectIdor the language pair. - Treating an arbitrary JSON object as a valid website bundle.
- Applying a bundle without validating it first.
See the shared getting-started guide in docs/package-getting-started.md for how this package relates to the SDK and framework wrappers.
API docs: https://api.mateza.rw/docs
API endpoint: https://api.mateza.rw
