Skip to content

Astro

The official @sonenta/astro integration pulls your released translation bundles from the Sonenta CDN at build time and inlines them into your static HTML: zero client JS, pure SSG, no flash of untranslated content. This site runs on it.

Sign in, create a project, and copy its UUID. You manage keys and translations in Sonenta: by talking to your agent over MCP, with the CLI, or in the dashboard.

Open the dashboard · MCP setup

Add the official Astro integration:

Fenêtre de terminal
npm install @sonenta/astro

Register it in astro.config.mjs with your project UUID, locales, and namespaces. Bundles are fetched once at build (locale × namespace). Extra options: version (default "main"), cdnBase, and fallbackLng.

astro.config.mjs
import { defineConfig } from "astro/config";
import sonenta from "@sonenta/astro";
export default defineConfig({
integrations: [
sonenta({
project: "<your-project-uuid>",
locales: ["en", "fr"],
defaultLocale: "en", // source / fallback locale
namespaces: ["common"],
}),
],
});

Import getT from the sonenta:i18n virtual module and bind it to a locale. Pass any locale you like: it works with Astro's native i18n routing or your own. Address other namespaces with the "ns:key" syntax (e.g. t("docs:intro")); strings are inlined into the static HTML:

src/pages/index.astro
---
import { getT } from "sonenta:i18n";
const t = getT(Astro.currentLocale ?? "en");
---
<h1>{t("home.title")}</h1>
<p>{t("home.greeting", { name: "Ada" })}</p>

Manage source strings in Sonenta and publish a release (via your agent, the CLI, or the dashboard). The next astro build picks up the latest bundle:

Fenêtre de terminal
# push your source strings to Sonenta + publish a release
npx @sonenta/cli push # or let your agent do it over MCP

CLI