With your agent / Existing site or app

Add a second language to your site or app

“All our texts are written into the code. Add German.”

For whoever has a working site or app in one language, with the texts inside the components, and wants a second language without going through every file by hand.

Prompt Replace the part in brackets, then paste it into your agent
Localize this app with i18next, in [English and German].
Run `npx i18next-cli localize --print-agent-prompt` and follow
the steps it prints, in order, checking each one before the next.

The command prints the steps for the i18next-cli version it runs, so the prompt does not go stale. When the project has no i18next configuration yet, your agent asks you one question before it writes one: where the translation files live.

What your agent does

  1. Checks the stack. React and Next work as they are; Vue and Svelte need a community plugin for i18next-cli. In Astro, instrument does not read .astro files, so your agent writes the t() calls, and i18next-cli-plugin-astro lets extract, status and lint read them.
  2. Writes the configuration (i18next.config.ts, or .js in a JavaScript project) with your languages: npx i18next-cli init --yes --locales en,de --backend local.
  3. Runs npx i18next-cli instrument --dry-run, then instrument: the hardcoded texts go through t() (in Next, await getT() in Server Components and useT() in Client Components). It lists the texts it left, and your agent moves those; it checks the diff and the warnings before it commits.
  4. Runs npx i18next-cli extract: every key lands in one JSON file per language and namespace.
  5. Translates the new language, then runs npx i18next-cli status (no text missing in any language) and npx i18next-cli lint (it warns when a translation drops a placeholder of the English).

Before it goes live

  • Have the new language read by someone who speaks it. An agent's translation is a first draft.
  • Look at the pages with the longest texts: German words are longer, buttons and table heads may wrap.
  • Add npx i18next-cli status to CI, so a text added later without its translation stops the build.

Writing the code yourself? Getting started and the i18next-cli docs describe each command.