Skip to content

Optional analytics, session recording and advertising stay off unless you accept. You can reject them and use Transglot. Change your choice anytime in Cookie preferences. Cookie Policy

Back to the blog
Developer platform

How to Translate a React or Next.js App Automatically

The three parts of automatic translation in a React or Next.js app, the tools that cover each part, and a setup that keeps every language current on each push.

by transglot team
published November 23, 2026
7 min read

Documentation reviewed 23 November 2026.

Quick answer

Translating a React or Next.js app automatically takes three parts: an i18n library that looks strings up at runtime, a source locale file those strings live in, and a step that translates that file into every other language whenever it changes. The first two are a one-time setup. The third is where tools differ, and it is the part worth automating, because a product that ships weekly changes its strings weekly.

Part 1: an i18n library

The library swaps a key for a string in the current language. The common choices are:

LibraryFitsMessage syntax
next-intlNext.js with the App RouterICU
react-i18nextReact apps in general, largest ecosystemi18next, with _one and _other suffix keys
FormatJS (react-intl)Apps that want ICU syntax everywhereICU

Any of them works with any translation tool, because they all read plain locale files, usually JSON.

With next-intl, a component reads a string like this:

tsxtsx
import { useTranslations } from 'next-intl';
export default function HomePage() {
const t = useTranslations('Home');
return (
<main>
<h1>{t('title')}</h1>
<p>{t('greeting', { name: 'Ada' })}</p>
<p>{t('items', { count: 3 })}</p>
</main>
);
}

With react-i18next the shape is the same:

tsxtsx
import { useTranslation } from 'react-i18next';
export function Header() {
const { t } = useTranslation();
return <h1>{t('home.title')}</h1>;
}

Part 2: one source file

Put every user-visible string in a source file, with a key per string. For the next-intl component above:

jsonjson
{
"Home": {
"title": "Welcome back",
"greeting": "Hello, {name}!",
"items": "{count, plural, one {# item} other {# items}}"
}
}

Save it as messages/en.json. Each other language gets a file of the same shape: messages/fr.json, messages/de.json.

Four rules save work later:

  • Write whole sentences as one string. Do not build a sentence from fragments, since word order differs by language.
  • Use the library's placeholder syntax, never string concatenation. Hello, {name}! can be reordered by a translator. 'Hello, ' + name cannot.
  • Use real plural syntax. The ICU form above lets each language have the plural forms it needs. Polish and Arabic need more than two.
  • Name keys by meaning, not by position. checkout.pay_button survives a redesign. page2.button3 does not.

i18next best practices covers key naming and namespaces in more depth.

Part 3: the translation step

This is the automatic part. There are three ways to do it.

ApproachHow it worksFits
Script and a model APIA script sends changed strings to a model and writes the filesOne developer, a few languages
A library that also translatesAn i18n library with translation built in, for example Lingo.dev or General TranslationTeams that want one package for both
Localization platformA service stores strings, translates on push, and gives reviewers an editor, for example Lokalise, Crowdin, Tolgee or TransglotTeams where non-developers review

A script is free and yours to maintain. How to translate JSON i18n files with AI walks through one. A platform costs money and adds review, a glossary, translation memory and checks. Pick by who will read the translations before users do.

If you compare platforms, compare what each one counts. The Lokalise, Crowdin and Tolgee comparisons price the same workload on each.

A working setup with Transglot

1. Connect the repository

From the root of a repository that already has messages/en.json:

bashbash
npx transglot@latest init --targets fr,de,es,ja

init finds the file, works out the source language, signs you in through the browser and runs the first translation. It writes a translated file for each language and a transglot.json:

jsonjson
{
"url": "https://api.transglot.ai",
"sources": [
{ "path": "messages/{locale}.json", "format": "json_nested", "locales": ["en"] }
],
"pull": [
{ "path": "messages/{locale}.json", "format": "json_nested" }
]
}

Commit both. Your i18n library now has the files it expects, with no change to your components.

2. Translate on every push

Create a deploy token with the push and pull abilities in the project, add it as a repository secret named TRANSGLOT_TOKEN, then add .github/workflows/transglot.yml:

yamlyaml
name: transglot
on:
push:
branches: [main]
jobs:
localize:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- uses: transglot/transglot-action@v1
with:
token: ${{ secrets.TRANSGLOT_TOKEN }}
url: https://api.transglot.ai

On each push to main, the action uploads the strings that changed, waits for the translation, pulls the files and commits them back. Only changed strings are translated, so an unchanged file costs nothing.

3. Know what the checks cover

Every string passes four checks before it is written: placeholders, plural forms, glossary terms and length. A string that fails placeholders, plurals or glossary is repaired once. If it still fails it is refused, and the job fails instead of merging a broken translation.

One detail for JSON: the format has no plural construct of its own. An ICU plural inside a string, as in the example above, is read and checked as a plural. i18next suffix keys such as items_one and items_other are ordinary keys, so a language that needs items_few or items_many needs those keys added. React localization CI checks shows how to catch a missing one in your own pipeline.

The command line tool and the action start on the Starter plan, $19 a month for 300,000 translated words. If the account is on Free, the browser offers a 14-day trial while you connect. See pricing.

Optional: update text without a deploy

By default the translated files live in your repository and ship with your build. If you want a wording fix to reach users without a release, load translations at runtime instead.

For Next.js:

bashbash
npm install @transglot/next
tsxtsx
import { loadTranslations } from '@transglot/next';
import { NextTranslateProvider } from '@transglot/next/client';
import type { ReactNode } from 'react';
export default async function LocaleLayout({
children,
params,
}: {
children: ReactNode;
params: Promise<{ locale: string }>;
}) {
const { locale } = await params;
const snapshot = await loadTranslations({
baseUrl: 'https://api.transglot.ai',
project: 42,
cdnKey: process.env.TRANSGLOT_CDN_KEY!,
locale,
});
return (
<html lang={locale}>
<body>
<NextTranslateProvider key={locale} snapshot={snapshot}>
{children}
</NextTranslateProvider>
</body>
</html>
);
}

@transglot/next fetches the published translations on the server, so the first render is already translated. It works with the App Router and the Pages Router on Next.js 14 or 15. Keep the CDN key in a server environment variable.

Two other packages cover the rest:

  • @transglot/react-i18n for a React app without Next.js.
  • @transglot/i18next-backend if you already use i18next or react-i18next. Your t() calls stay as they are and only the source of the files changes.

Runtime delivery is on the Starter plan and above. The runtime SDK guide lists every package.

Common mistakes

  • Translating keys. A model given raw JSON sometimes translates "title" as well as its value. Send values only, or use a tool that parses the file.
  • Hardcoded strings left behind. Text in aria-label, placeholder, alt, error messages and metadata is easy to miss. Search for them.
  • Dates, numbers and currency formatted by hand. Use Intl.DateTimeFormat and Intl.NumberFormat, or your library's formatters, so each language gets its own format.
  • One layout for every language. German runs about a third longer than English, and Arabic and Hebrew read right to left. Test the longest language and one right-to-left language.
  • No language in the URL. Search engines index one URL per language. Use a locale segment such as /fr/pricing and set the lang attribute on the html element.

Frequently asked questions

Do I need an i18n library if I use a translation tool?

Yes, in most setups. The tool produces translated files; the library reads them in the browser or on the server. Tools such as Lingo.dev and General Translation are the exception, since they ship their own library.

Will automatic translation break my placeholders?

It can, which is why a check after translation matters. Compare the placeholders of each translated string with its source. Transglot does this on every string and refuses one it cannot repair.

How do I translate only what changed?

Keep a record of what was already translated. A script can store a hash per key. A platform does it for you: pushing an unchanged file translates nothing.

How many languages can I add?

As many as your library and your reviewers can handle. Transglot accepts any standard language tag and its Free plan holds 14 target languages in one project.

Does this work with the Pages Router and with plain React?

Yes. The translation step only reads and writes locale files, so it does not depend on the router or the framework. For runtime delivery, @transglot/next supports both routers and @transglot/react-i18n covers React without Next.js.

How this guide was checked

  • Library descriptions follow each project's own documentation, linked under Sources.
  • The configuration, workflow and SDK examples are taken from the product documentation on the review date.
  • The three approaches in Part 3 are described by how they work, not ranked. A script is the right choice for many small projects, and the guide says so.
  • The other platforms named were not tested for this guide, so it makes no claim about which translates best.

Sources

colophon

Who wrote this, and what to read next

wrote this

transglot team

The byline on this post has no profile yet. Author profiles are managed alongside the posts themselves.

Engineering
Developer platform
keep reading

React localization: check keys, variables and plurals

Build a small React localization workflow with i18next. Catch missing keys, renamed variables and plural errors before deployment with a Node.js CI check.

November 9, 2026
10 min read
keep reading

i18next best practices for scalable apps

Scale i18next with deliberate namespaces, correct plural lookups, safe interpolation and explicit fallback rules. Includes working examples and a release checklist.

February 3, 2026
6 min read
works with what you already run

41 connectors, already built.

the pipeline this post describes

Try it on your own strings. Free, no card.

Free plan: 100,000 words to start (25,000 at sign-up, 75,000 after a phone check), then 10,000 a month, 15 locales including your source, 3 seats.