# Add i18n to a Flutter App

Yes. An agent adds flutter_localizations and gen-l10n to your Flutter app, moves every string into ARB files, localizes dates and amounts, adds a language, in a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-i18n/flutter/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads every string a user can see and where it is built. In an app laid out like `form_app` in flutter/samples, `pubspec.yaml` is on SDK `^3.9.0-0` with `intl`, `http`, `go_router`, `english_words` and `json_annotation`, `resolution: workspace` and `uses-material-design: true`; `lib/main.dart` builds a `MaterialApp.router` titled `Form Samples`, a `HomePage` whose `AppBar` repeats it, and a `demos` list whose names, `Sign in with HTTP`, `Autofill`, `Form widgets` and `Validation`, become `ListTile` titles. `lib/src/form_widgets.dart` has labels and hints such as `Title`, `Enter a title...`, `Description`, `Estimated value`, `Brushed Teeth`, `Enable feature`, `Date` and `Edit`, formats the slider's value with `intl.NumberFormat.currency(symbol: "\$", decimalDigits: 0)` and the date with `intl.DateFormat.yMd()`, both without a locale; `lib/src/validation.dart` has the `📖 Story Generator` title, `Submit`, `Your story`, the interpolated `The $adjective developer saw a $noun`, `Done`, and validator messages such as `Please enter an adjective.` and `You must agree to the terms of service.`; `lib/src/autofill.dart` has eight labels and hints; `lib/src/sign_in_http.dart` has `Sign in Form`, `Email`, `Password`, `Sign in`, `Successfully signed in.`, `Unable to sign in.`, `Something went wrong. Please try again.` and `OK`. `test/form_app_test.dart` pumps `MaterialApp(home: SignInHttpDemo(httpClient: mockClient))` with no delegates and finds the two sign-in messages by their English text.

The setup is the one the Flutter tooling generates for. The agent adds `flutter_localizations` from the SDK and `generate: true` under `flutter:` in `pubspec.yaml`, writes `l10n.yaml` with `arb-dir: lib/l10n`, `template-arb-file: app_en.arb` and `output-localization-file: app_localizations.dart`, and creates `lib/l10n/app_en.arb` with one key per string and a `@`-entry with a description for each, using placeholders where the code interpolates: `storyLine` takes `adjective` and `noun`, so the sentence can be reordered in a language that puts the noun first. `flutter gen-l10n` produces `AppLocalizations`, and `main.dart` passes `AppLocalizations.localizationsDelegates` and `AppLocalizations.supportedLocales` to `MaterialApp.router` and takes its `title` from `onGenerateTitle` so the app's name follows the locale too. Every `Text('...')`, `labelText`, `hintText` and validator message becomes `AppLocalizations.of(context)!.<key>`, which drops `const` from those constructors, so the agent also runs the analyzer, since `analysis_defaults` brings `flutter_lints` and its `prefer_const_constructors` hint, and keeps `const` wherever a widget no longer holds a string.

Numbers and dates get the locale too: `NumberFormat.currency` and `DateFormat.yMd` take `Localizations.localeOf(context).toString()`, and the currency symbol becomes a locale-aware `simpleCurrency` call with the example's dollar kept as the `en` default, because a form that shows an estimated value in dollars to a German reader with a US thousands separator is the kind of half-done i18n a reviewer catches. The second language is Spanish, in `lib/l10n/app_es.arb`, with every key translated and marked in the pull request as the agent's draft for a translator's review. One thing deliberately stays English: `validation.dart` checks the typed word against `english_words.adjectives` and `english_words.nouns`, so the field accepts English words only no matter the locale; the agent localizes the messages and the labels, leaves the check, and says in the pull request that a per-language word list is a product decision.

Tests prove the switch rather than the strings alone. `_signIn` in `test/form_app_test.dart` now pumps the demo inside a `MaterialApp` with the generated delegates and supported locales, so the two existing tests pass on the English text they already look for; a new test pumps the same widget with `locale: const Locale('es')` and finds the Spanish success message, and another renders `FormWidgetsDemo` under `es` and asserts the date and the amount use that locale's format. The agent runs `flutter gen-l10n`, `flutter analyze` and `flutter test` in its sandbox on the SDK the workspace resolves, and the pull request lists each key with its English and Spanish value so the translator's review is a read of two ARB files.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add internationalization to this Flutter app with the SDK's gen-l10n tooling. Read pubspec.yaml, analysis_options.yaml, lib/main.dart, every file under lib/src and test/form_app_test.dart first and list every user-visible string, label, hint, validator message and dialog text. Add flutter_localizations and generate: true to pubspec.yaml, write l10n.yaml with arb-dir lib/l10n and app_en.arb as the template, and put every string in app_en.arb with a description, using placeholders where the code interpolates values. Pass the generated delegates and supported locales to MaterialApp.router and take the app title from onGenerateTitle. Replace each string in the widgets with AppLocalizations.of(context) lookups, keeping const where a widget no longer holds a string, and give NumberFormat and DateFormat the locale from Localizations.localeOf. Add app_es.arb with a Spanish draft of every key and say in the pull request that it needs a translator's review. Leave the english_words validation check as it is and explain why. Update the existing tests to pump with the delegates, add a test under the Spanish locale for the sign-in message and one for the localized date and amount. Run flutter gen-l10n, flutter analyze and flutter test, and open a pull request listing every key with both values.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

The pull request adds `l10n.yaml`, `lib/l10n/app_en.arb` and `lib/l10n/app_es.arb`, changes `pubspec.yaml`, `lib/main.dart`, the four files under `lib/src` and the test file, and nothing else. Its description shows `flutter gen-l10n`, `flutter analyze` with no issues, the `flutter test` summary with the two existing tests and the two new ones passing, and a table of every key with its English and Spanish value.

Nothing changes for an English reader: the same labels, hints and messages in the same places, the date still in `M/d/y` form and the estimated value still in dollars. A device set to Spanish gets the Spanish strings, a Spanish date order and a Spanish-formatted amount, and any other locale falls back to English through the generated delegate. The `english_words` validation still accepts English words only.

Before merging, a reviewer sends `app_es.arb` to a translator, decides whether the estimated value should stay in dollars for every locale or follow the device's currency, which the pull request shows as a one-argument choice, and decides whether the English-only validation is acceptable for the languages they plan to ship.

## Run it on every Linear issue labelled i18n

A team that tracks localization in Linear starts one run per issue from an automation with a `linear` trigger on the `i18n` label. The automation adds the issue after this prompt, so a screen the issue says still shows English, or a third language it asks for, is what the agent reads, and the run starts in the repository the automation names.

Each run opens its own pull request from its own sandbox, and an automation run has its own `max_runs_per_hour` cap. The pull request links the issue and lists each key and both values, so a translator's review is a read of the ARB files and nothing else.

## Why run it on Rush?

Adding i18n to a Flutter app is mostly a long, careful move of strings into ARB files, and the ways it goes wrong are quiet: a `const` left on a widget that now needs context, a date that follows the locale while the number beside it does not, a sentence interpolated in English word order, a test that still pumps without delegates and fails on the first lookup. The agent runs `gen-l10n`, the analyzer and the tests in its own sandbox on the SDK the workspace pins, so each of those is caught before the pull request exists.

The transcript keeps the analyzer and test output and the generated keys, so a reviewer reads the table of strings and the green run without opening Flutter. Several apps can be localized at once, each in its own sandbox, and nothing merges until a person and a translator read the diff.

## Frequently asked questions

### Why gen-l10n and ARB rather than a package?

It is the SDK's own path: `flutter_localizations` ships with Flutter, `l10n.yaml` and `generate: true` make `flutter pub get` regenerate `AppLocalizations`, and ARB is what translation tools read. The app gains no dependency, and the generated class is typed, so a missing key is a compile error rather than a string shown as its own name.

### What happens to the const constructors?

A `const Text('Title')` becomes `Text(AppLocalizations.of(context)!.title)`, which cannot be `const`, and the analyzer's `prefer_const_constructors` hint from `flutter_lints` reminds you where `const` can stay. The agent keeps it on every widget that no longer holds a string, such as `SizedBox` spacers and `InputDecoration` borders, and the pull request's `flutter analyze` run shows no new hints.

### Is the Spanish translation final?

No. It is the agent's draft so the app can be run and tested under a second locale, and the pull request says a translator should review `app_es.arb` before release. The point of the change is that the next language is one ARB file with no code.

### Why does the validation still accept English words only?

`validation.dart` checks the typed word against the `english_words` package's lists, which is the demo's point and has no Spanish counterpart in the package. Localizing the labels and messages around it is the i18n work; choosing a word list per language changes what the form does, so the pull request leaves it and names the decision.

### How are the tests affected?

The existing tests pumped `SignInHttpDemo` inside a bare `MaterialApp`, which has no localization delegates, so the first `AppLocalizations.of(context)` would fail. The helper now pumps with the generated delegates and supported locales, the two existing tests pass unchanged on their English text, and two new tests run under `Locale('es')`.

## More Flutter jobs

- [Add Integration Tests to a Flutter App](https://getrush.ai/run/add-integration-tests/flutter/)
- [Add Local Notifications to a Flutter App](https://getrush.ai/run/add-local-notifications/flutter/)
- [Add a Native Splash Screen to a Flutter App](https://getrush.ai/run/add-splash-screen/flutter/)

## The same job on other stacks

- [Add i18n to a Gatsby Blog](https://getrush.ai/run/add-i18n/gatsby/)
- [Add i18n to a Hugo Site](https://getrush.ai/run/add-i18n/hugo/)
- [Add i18n to a Leptos App](https://getrush.ai/run/add-i18n/leptos/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
