Add Japanese & Spanish to a Next.js App
Devin installs next-i18next, extracts hardcoded strings into locale JSON files, adds Japanese and Spanish translations, and verifies language switching in the browser.(Optional) Scope the codebase with Ask Devin
If you’re not sure how your Next.js app is structured or which components contain hardcoded strings, use Ask Devin to investigate first:You can also start a Devin session directly from Ask Devin, and it will carry over everything it learned as context.
Kick off the i18n setup
Adding internationalization to a Next.js app means wiring up locale routing, configuring middleware, extracting every hardcoded string, and creating translation files — all before you can test a single language switch. Devin handles the entire pipeline: installing
next-i18next, configuring Next.js locale routing, extracting strings from dozens of components, and verifying the result in the browser.Use the /plan slash command at the start of the session so Devin investigates your codebase first — it will figure out whether you’re using the Pages Router or App Router, identify the right i18n library, and outline its approach before writing any code. Review the plan and suggest changes before it starts.How Devin handles the setup
Devin works through your Next.js codebase methodically — configuring the i18n pipeline, extracting strings, and building locale files. Here’s what that looks like:
- Installs dependencies — Runs
npm install next-i18next i18next react-i18nextand creates the config files:
-
Scans every component — Reads each file in
components/andpages/, identifying hardcoded text in JSX, attributes likeplaceholderandaria-label, template literals, and error strings -
Builds locale files — Creates structured JSON under
public/locales/:
-
Replaces strings in-place — Wraps each component with
useTranslation('common')and swaps hardcoded text fort()calls, handling interpolation for dynamic values liket('dashboard.welcome', { name: user.name }) -
Wires up server-side loading — Adds
serverSideTranslationsto each page so translations are available at render time:
- Adds the language switcher — Builds a dropdown in the navbar that uses Next.js router locale switching:
Test and iterate
Devin runs
npm run dev, opens the app in its built-in browser, and navigates between /en, /es, and /ja routes to verify everything works. If something is broken — a missing translation, a layout that overflows, a route that 404s — Devin fixes it and re-tests automatically.Use the /test slash command at any point to tell Devin to re-run all tests and re-verify in the browser. Use /review before the final PR to have Devin review its own code for missed strings, inconsistent key naming, or missing serverSideTranslations calls.Devin checks:- All visible text is translated (no leftover English strings in Spanish/Japanese mode)
- Layouts don’t break with longer Spanish strings or wider Japanese characters
- The language switcher toggles between all three locales
- Interpolated values (usernames, counts) render correctly in each locale
- Pluralization rules work (e.g., “1 item” → “1 件” in Japanese, “1 elemento” in Spanish)
- Next.js locale routing works —
/ja/dashboardshows the Japanese version
Update your repo setup
This task installs new dependencies (
next-i18next, i18next, react-i18next). After the PR merges, update your repo setup so Devin’s environment snapshot includes these packages for future sessions:- Go to Settings > Devin’s Environment > Repositories
- Select your repo and click Configure
- Under Upkeep > Maintain dependencies, make sure your install command (e.g.,
npm ci) is set - Click Save to update the snapshot
package.json evolves, so future sessions don’t waste time installing packages at startup.Review the PR with Devin Review
Once Devin opens the PR, use Devin Review to review the i18n changes. Devin Review can catch missed hardcoded strings, inconsistent translation key naming, and missing
serverSideTranslations calls across pages.