# How do I translate a React Native app?

49.5 s · Narrator: Frederick Surrey

Install gt-react-native, add its Babel plugin for the Intl polyfills, call initializeGT and wrap your app in GTProvider, mark text with the T component, and run npx gt translate to write a translation file for each language. The package is experimental, and Expo Go is not supported, so Expo apps need a development build.

| Time | Voice | Line | On screen |
| --- | --- | --- | --- |
| 0:00.88 | Narrator | In Lyon, your app opens in English on a phone set to French. | A phone draws in the middle of the frame: a plain outline with a speaker slot at the top and a home bar at the bottom. On "your" the heading "Your app opens in English" rises, and the app's welcome, "Welcome to my app", rises with three bars of copy under it; on "English" the welcome turns blue. On "set" the language code `fr` appears over the phone's top right corner: the phone is set to French. |
| 0:05.08 | Narrator | Its welcome is a plain Text element that nothing translates. | On "Its" the phone slides to the right. On "welcome" a code panel opens with `src/Home.tsx`, whose `Home` returns `<Text>Welcome to my app</Text>` inside a `View`. On "Text" the blue moves from the welcome to that line, and on "that" a line joins it to the welcome on the phone. |
| 0:09.38 | Narrator | General Translation lets you translate a React Native app with gt-react-native and T. | The answer card cuts in on "General": the answer alone rises as it is spoken, in two lines, "General Translation lets you translate" then "a React Native app with gt-react-native and <T>", and the General Translation mark sits small in the lower left corner. |
| 0:15.80 | Narrator | Add its Babel plugin, which supplies the polyfills React Native needs. | The heading "Add the Babel plugin". The code panel opens again with a new `babel.config.js`: the plugin, `require('gt-react-native/plugin')`, and the config, `require('./gt.config.json')`, at the top, and in `plugins` the plugin with `config: gtConfig` and `entryPointFilePath: require.resolve('expo-router/entry')`. On "plugin" the two `require` calls turn blue. On "which" a file panel opens on the right with the project's files: `app/` with `_layout.tsx` and `index.tsx`, `src/` with `Home.tsx`, `babel.config.js` and `gt.config.json`. On "polyfills" the blue moves to the plugin's lines in `plugins`, and on "needs" a white box draws around them. |
| 0:20.80 | Narrator | Call initializeGT with loadTranslations, then wrap the app in GTProvider, which reads the device language. | The code panel cuts to `app/_layout.tsx`, a root layout that returns `<Slot />`. On "Call" three imports open at the top: `GTProvider` and `initializeGT` from `gt-react-native`, `gtConfig` from `../gt.config.json`, and `loadTranslations` from `../loadTranslations`. On "initializeGT" the line `initializeGT({ ...gtConfig, loadTranslations });` opens. On "loadTranslations" the panel cuts to `loadTranslations.ts`, which requires `./src/_gt/es.json`, `fr.json` and `ja.json`, and whose async `loadTranslations` returns the one for a locale, and the file appears in the file panel. On "then" the panel cuts back to `app/_layout.tsx`, and the heading "Wrap the app in <GTProvider>" rises on "wrap". On "GTProvider" the return becomes `<GTProvider><Slot /></GTProvider>`, and on "device" a white box draws around it. A blue bar marks each changed line. |
| 0:28.50 | Narrator | Mark the welcome with T, then sign in and run npx gt translate. | The heading "Mark the welcome with <T>", and the code panel cuts to `src/Home.tsx` as it stood before. On "welcome" `import { T } from 'gt-react-native';` opens under the first import, and on "T" the welcome's line becomes `<T><Text>Welcome to my app</Text></T>`. A blue bar marks each changed line. On "sign" the panel cuts to a terminal, where `npx gt login` is typed, and on "run" `GT_PROJECT_ID=your-project-id npx gt translate` is typed on the next line. On "translate" `src/_gt/` appears in the file panel with `es.json`, `fr.json` and `ja.json` under it. |
| 0:34.26 | Narrator | The package is experimental, and Expo apps need a development build. | The code panel cuts to a new terminal. On "package" `npx expo run:ios`, which makes a development build, is typed there, marked in blue. The heading "A development build for Expo" rises on "Expo", and on "build" a white box draws around the command. |
| 0:38.70 | Narrator | Phones set to Spanish or Japanese show them, and in Lyon the app opens in French. | The phone cuts back in the middle of the frame with the code `en`, its welcome in English. On "Spanish" it cuts to a phone set to Spanish, its welcome in Spanish under the code `es`; on "Japanese" to a phone set to Japanese, under `ja`; and on "Lyon" to the phone set to French, under `fr`, its welcome in French. On "French" the welcome turns blue, in the place where the English welcome turned blue at the start. |
| 0:44.26 | No voice |  | The end card: the General Translation logo with generaltranslation.com/docs/react/react-native-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.
