# How do I add i18n to a Next.js app?

52.8 s · Narrator: Frederick Surrey

Install gt-next and the gt CLI, wrap your Next.js config with withGTConfig, list your languages in gt.config.json, add a loadTranslations file and the GTProvider, wrap your content in the T component, and run npx gt translate before next build.

| Time | Voice | Line | On screen |
| --- | --- | --- | --- |
| 0:00.88 | Narrator | In Osaka, your page is in English, with no way to choose Japanese. | An app page draws in the middle of the frame. On "Osaka" the language code `en` appears over its top right corner: the language the reader's browser asks for. On "page" the heading "Welcome to my app" and the line "This content will be translated automatically." rise, with nothing above the heading, and on "English" the heading turns blue. The heading "No way to choose Japanese" rises on "no". |
| 0:05.62 | Narrator | Its text is plain JSX, and the app has no i18n library. | On "Its" the page slides to the right, and on "text" a code panel opens with `app/page.tsx`: a `Home` component whose `<main>` holds `<h1>Welcome to my app</h1>` and the paragraph. On "JSX" the blue moves from the page to `Welcome to my app` in the code, on "and" a line joins that row to the page's heading, and on "library" a white box draws around the whole file, which has no import and no provider. |
| 0:11.66 | Narrator | General Translation lets you add i18n with gt-next: wrap text in T and generate translations. | The answer card cuts in on "General": the answer alone rises as it is spoken, in two lines, "General Translation lets you add i18n with gt-next:" then "wrap text in <T> and generate translations", and the General Translation mark sits small in the lower left corner. |
| 0:20.78 | Narrator | Wrap your config in withGTConfig, list your languages, and add a file that loads their translations. | The heading "Wrap your config in withGTConfig", and the code panel opens again with `next.config.ts`. On "config" `import { withGTConfig } from 'gt-next/config';` opens at the top, and on "withGTConfig" the export becomes `export default withGTConfig(nextConfig);`, each marked by a blue bar; then a file panel opens on the right with the project's files. On "list" the code panel cuts to `gt.config.json`, which joins the files, and on "languages" `"es"`, `"fr"` and `"ja"` turn blue. On "add" the panel cuts to `src/loadTranslations.ts`, on "file" `src/` and `loadTranslations.ts` join the files, and on "translations" a white box draws around its import of `../public/_gt/${locale}.json`. |
| 0:27.92 | Narrator | Put the GTProvider in your root layout, wrap text in T, and add a LocaleSelector for the menu. | The heading "Add GTProvider to the layout", and the code panel cuts to `app/layout.tsx`. `import { GTProvider, useLocale } from 'gt-next';` opens at the top, `{children}` becomes `<GTProvider>{children}</GTProvider>`, `const locale = useLocale();` opens, and `<html lang="en">` becomes `<html lang={locale}>`. On "wrap" the panel cuts to `app/page.tsx`: its heading and paragraph move in, `<T>` and `</T>` open around them, `import { T, LocaleSelector } from 'gt-next';` opens at the top, and `<LocaleSelector />` opens above `<T>`. A blue bar marks each changed line, and on "menu" a white box draws around `<LocaleSelector />`. |
| 0:34.82 | Narrator | Run npx gt translate before next build to write a file for each language. | The heading "Run npx gt translate before next build", and the code panel cuts to `package.json`. On "npx" `npx gt translate && ` is typed in front of `next build`, marked by a blue bar, and on "build" a white box draws around the line. On "write" a line joins it to the file panel, and on "file" `public/_gt/` appears with `es.json`, `fr.json` and `ja.json` under it. |
| 0:40.34 | Narrator | In Osaka, the menu now offers Spanish, French and Japanese, and the reader picks Japanese. | The app page cuts back in the middle of the frame, in English, now with a language menu above its heading that reads "English"; the language code is gone. On "menu" a white box draws around the menu. On "Spanish", "French" and "Japanese" the menu and the page switch to that language. On the second "Japanese" the Japanese heading turns blue, in the place where the English heading turned blue at the start. |
| 0:47.62 | No voice |  | The end card: the General Translation logo with generaltranslation.com/docs/react/nextjs-quickstart under it, held to the last frame while the music ends on a held chord. |

Times are where each line starts in the final, read from the film's own audio.
