i18next in Astro
Translate an Astro site with plain i18next: Astro gives each language its address, i18next the texts, and a static build ships no JavaScript for it.
Set up i18next in Astro with your coding agent
Paste this prompt into Claude Code, Cursor, Codex, GitHub Copilot, Gemini CLI or any agent that can run terminal commands:
Localize this app with i18next.
Run `npx i18next-cli localize --print-agent-prompt` and follow
the steps it prints, in order, checking each one before the next.
Your agent follows the steps the CLI prints for your project and writes the translation files; you review the diff, and the files stay in your repository unless you choose a translation management service. The CLI does not wrap texts in .astro files yet.
⇒ What the prompt tells your agent
In Astro, a page file under src/pages/[lang]/ gives every language its own address (/en/, /de/), and Astro's
built-in i18n routing adds the redirect and the URL helpers. It has no t(): no plurals, no interpolation, no fallbacks. Plain
i18next adds them while Astro renders the pages. In a static build it runs only at build time: the test of
(Astro 7.4.13, i18next 27.2.2) wrote one HTML file per language and page, with no JavaScript file and no script tag.
No integration package is needed. You need three things: i18next, your translation files, and for the checks
i18next-cli with i18next-cli-plugin-astro.
What there is
- Getting started: one address per language, i18next once for the whole build, the pages, the language switch with hreflang.
- The CLI plugin:
extract,statusandlintread.astrofiles, and a missing translation stops the build. - When the texts change, and interactive parts: a changed text needs a new build; an interactive island uses the binding of its framework.