Point Polyglot at a Next.js App Router project and it converts hardcoded JSX text into next-intl calls — hooks injected, catalogs written, wiring verified.
next-intl is the App Router's de-facto i18n library — and the tedious part of adopting it is never the library. It's the hundreds of hardcoded strings already in your JSX. Polyglot's wrap command finds every one with a real parser (tree-sitter, not regex), rewrites the call sites, and writes the catalog next-intl loads.
"use client";
export default function Page() {
return (
<main>
<h1>Welcome back</h1>
<p>Your projects are ready</p>
<input placeholder="Search projects" />
</main>
);
}"use client";
import { useTranslations } from "next-intl";
export default function Page() {
const t = useTranslations("src.app.page");
return (
<main>
<h1>{t('welcome_back')}</h1>
<p>{t('your_projects_are_ready')}</p>
<input placeholder={t('search_projects')} />
</main>
);
}Text nodes become t() calls, attributes like placeholder become expressions, and the useTranslations hook is injected into each component that needs it — including the import.
Keys are namespaced by file path and written to messages/en.json, the exact layout next-intl's getRequestConfig loads. Your target languages get their catalog files created alongside — empty on purpose, so next-intl's loader resolves immediately — and polyglot translate fills them.
{
"src": {
"app": {
"page": {
"search_projects": "Search projects",
"welcome_back": "Welcome back",
"your_projects_are_ready": "Your projects are ready"
}
}
}
}{
"src": {
"app": {
"page": {
"search_projects": "Projekte suchen",
"welcome_back": "Willkommen zurück",
"your_projects_are_ready": "Ihre Projekte sind bereit"
}
}
}
}{
"src": {
"app": {
"page": {
"search_projects": "Rechercher des projets",
"welcome_back": "Bon retour",
"your_projects_are_ready": "Vos projets sont prêts"
}
}
}
}$ curl -fsSL https://getpolyglot.ai/install.sh | sh
$ polyglot init --framework nextjs
$ polyglot scan
$ polyglot wrap
$ polyglot translate --languages de # 50 strings free, no signupwrap and scan run entirely offline — the dry run shows every change before anything is written. Your first 50 translated strings are free, no signup.
Im Terminal starten
Installieren Sie die CLI, führen Sie einen Scan durch und sehen Sie genau, was Ihnen fehlt. Kostenlos, kein Konto erforderlich.