Your Next.js app works, it has users, and every label is hard-coded in English. Someone asks for a French version. You open next-intl's docs, and realise the setup takes an afternoon and the extraction takes a week.
This post shows both: what the setup looks like by hand, and how to get the same result with three commands.
1. Why hard-coded text gets expensive
Hard-coded strings are free until the second language. Then every <button>Save</button>, every toast.success("Saved"), every placeholder="Search" and every `${n} files` has to become a key, live in a JSON file, and be called through t(). The longer you wait, the more strings there are, and the more of them hide in places a quick search misses: metadata, validation messages, constants mapped into a <Select>, helper functions.
2. The next-intl setup by hand
With the App Router, next-intl needs:
-
i18n/routing.ts(your locales and the default one),i18n/request.ts(loads the messages),i18n/navigation.ts(locale-awareLink,useRouter,usePathname) -
proxy.ts(middleware.tsbefore Next.js 16) to redirect/to/en - every page moved under
app/[locale]/, with the relative imports fixed - the plugin in
next.config -
messages/en.json,messages/fr.json… - every
next/linkimport switched toi18n/navigation, or links lose the language
None of it is hard. All of it is easy to get slightly wrong.
3. init does the same thing
npx alinea-cli init --locales en,fr,de It creates what is missing and never overwrites an existing file: the three i18n/ files, the proxy, app/[locale]/layout.tsx (on Next.js 16.3+ your root layout moves there with fonts, CSS and metadata kept), your pages moved into [locale] with imports fixed, the plugin, one message file per language, and next-intl installed with your package manager. Run it again later with --locales es to add a language.
4. scan: move the texts out of your components
npx alinea-cli scan src Before:
export function Members({ count }: { count: number }) { return ( <section> <h2>Team members</h2> <p>{count} {count === 1 ? 'member' : 'members'}</p> <input placeholder="Search by name" /> </section> ); } After:
import { useTranslations } from 'next-intl'; export function Members({ count }: { count: number }) { const t = useTranslations('Members'); return ( <section> <h2>{t('teamMembers')}</h2> <p>{t('memberCount', { count })}</p> <input placeholder={t('searchByName')} /> </section> ); } And in messages/en.json (keys are made from the text; --stable-keys gives key_1, key_2… instead):
{ "Members": { "teamMembers": "Team members", "memberCount": "{count, plural, one {# member} other {# members}}", "searchByName": "Search by name" } } The scan also handles rich text (Read our <link>terms</link>. becomes one message with t.rich()), metadata (turned into generateMetadata()), toasts and validation messages, constants used across files (wrapped with localize(t, …) at every use) and Server Actions. What it leaves alone: dynamic values, values your code compares or stores, CSS classes, URLs, ids.
Nothing is skipped silently: the scan ends with the list of texts it could not convert, with the file, the line and what to do. Commit before scanning, then review the diff like any other PR.
5. translate
npx alinea-cli translate It fills fr.json and de.json with the same structure and key order as en.json. Only missing keys are sent, so after the first run a new release costs a few characters. {variables}, plural branches and tags are kept intact, and a translation whose placeholders came back damaged is never written. Brand and people names are never sent to the engine.
Engines: bring your own key with --engine deepl (DEEPL_API_KEY) or --engine openai (OPENAI_API_KEY), or use the default Addongo engine (open translation models on our own servers, 100 languages).
6. Keep CI green
Two checks stop untranslated text from coming back:
npx alinea-cli scan src --strict --dry-run # fails if new hard-coded text appears npx alinea-cli status --check # fails if a language is missing keys Try it
npx alinea-cli init npx alinea-cli scan src npx alinea-cli translate Node.js 20+, a Next.js app with the App Router, run from the project root. Docs: addongo.com/en/docs/quickstart. The CLI is free; feedback on edge cases the scan misses is very welcome in the comments.