# Add i18n to an Angular App

Yes. An agent adds @angular/localize to your Angular app, marks the templates, extracts the messages, wires a second locale into the build and opens a PR.

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

## What the agent does

The agent reads the workspace before it touches a template. In an Angular app like `realworld-apps/angular-realworld-example-app`, `package.json` pins `@angular/core` 21.2.12 with `@angular/build` and `@angular/cli` 21.2.10, runs on Bun (`bun.lock`, `oven-sh/setup-bun` in every workflow), tests with Vitest 4 through `@analogjs/vite-plugin-angular` in a jsdom environment, and runs Playwright for end to end with `test:e2e` excluding `@security` specs. `angular.json` has one project, `angular-conduit`, built by `@angular/build:application` from `src/main.ts` with an empty `polyfills` array, assets and the stylesheet pulled from the `realworld` git submodule, and an `extract-i18n` target that already uses `@angular/build:extract-i18n`. `src/app/app.config.ts` bootstraps with `provideZonelessChangeDetection()`, `provideRouter(routes)` and three HTTP interceptors; `src/app/app.routes.ts` lazy-loads every page with `loadComponent`. `src/index.html` has no `lang` attribute.

The strings live in the templates and a few TypeScript files. `src/app/core/layout/header.component.html` has Home, Sign in, Sign up, New Article, Settings, Loading and Connecting in `@if` blocks on the auth state; `src/app/features/article/pages/home/home.component.html` has Your Feed and Global Feed and the banner text; the auth, editor, settings, profile and article pages carry their own labels, and `src/app/shared/components/list-errors.component.html` renders error text. The agent installs `@angular/localize` with `bun add`, adds `@angular/localize/init` to the `polyfills` array in `angular.json` so `$localize` exists at runtime, and tags each user-facing element with `i18n`, each `title` and `placeholder` with `i18n-title` and `i18n-placeholder`, giving every message a stable custom id so a later edit does not orphan its translation. Strings built in TypeScript, such as the fallback `Failed to load article` in `article.component.ts`, become `$localize` template literals.

Then it extracts and wires the locales. `bun run ng extract-i18n --output-path src/locale` writes `src/locale/messages.xlf`; the agent copies it to `messages.<locale>.xlf` for the second locale you name and fills the `<target>` elements with a translation marked as needing review, since the translation itself is a human's job. `angular.json` gets an `i18n` block with `sourceLocale: en` and the new locale mapped to its file, the production configuration gets `localize: true` so `ng build` writes `dist/angular-conduit/browser/en` and a sibling for the new locale, and the development configuration gets `localize: ["en"]` so `ng serve` keeps one bundle. Because `.github/workflows/deploy.yml` zips `dist/angular-conduit/browser`, the agent updates that step for the per-locale directories and notes the `_redirects` asset that now needs a locale prefix. `src/index.html` gets a `lang` attribute, which the localized builds rewrite per locale.

Tests have to keep running. `vitest.config.ts` loads `src/test-setup.ts`, which initialises the TestBed with `BrowserDynamicTestingModule`; the agent adds `import '@angular/localize/init'` at its top so components that use `$localize` render in the suite, then runs `bun run test`. Playwright specs that read the page by text keep matching because the source locale is unchanged, and the agent runs `bun run test:e2e` after `bunx playwright install --with-deps chromium` as `.github/workflows/playwright.yml` does. `bun run format:check` runs last, since `lint.yml` fails on Prettier drift and the `i18n` attributes change line wrapping in several templates.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "A Linear issue labelled agent says: \"Add i18n. Use Angular's built-in localize, mark every user-facing string, extract the messages file and set up one more locale, es, so the build produces both.\" Do the work in this repository. Read package.json, angular.json, src/main.ts, src/index.html, src/app/app.config.ts, src/app/app.routes.ts, src/app/core/layout/header.component.html, src/app/features/article/pages/home/home.component.html, the other page templates under src/app, src/test-setup.ts, vitest.config.ts, playwright.config.ts and the workflows under .github/workflows first. Add @angular/localize with bun, put @angular/localize/init in the polyfills, tag every user-facing element and attribute with i18n and a stable custom id, convert strings built in TypeScript to $localize, run ng extract-i18n to src/locale, create the es file with targets marked for review, add the i18n block and localize settings to angular.json, update the deploy workflow for per-locale output directories, and import @angular/localize/init in the test setup. Run bun run test, bun run build, bun run test:e2e after installing the Playwright browser, and bun run format:check, and open a pull request that lists the message count and where translators edit the es file.",
  "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

What comes back is a pull request that adds `src/locale/messages.xlf` and `src/locale/messages.es.xlf`, changes `angular.json`, `package.json` and `bun.lock`, `src/index.html`, `src/test-setup.ts`, every template with user-facing text, the TypeScript files that built strings by hand, and the deploy workflow. The description says how many messages were extracted, where the `es` file is and how its review markers work, which output directories the build now produces, and quotes the test, build, Playwright and format summaries.

The transcript holds the `bun add`, the extraction with its message count, the production build listing both locale directories, the Vitest and Playwright runs and the Prettier check, so a reviewer sees two bundles built and the suites green rather than reading that they should be. The repository's `Format Check` and `Playwright Tests` workflows run again on the pull request.

Before merging, a reviewer checks that no string was tagged twice or split across elements in a way that produces a fragmented message, that interpolations such as the username in the header kept their placeholders, that the custom ids are stable and descriptive, that `_redirects` and the deploy step match the new directory layout, and that the Spanish targets are clearly marked for a translator. A follow-up message to the same session adds a locale switcher that links between the two builds, and the sandbox already has the dependencies and the browser.

## Run it on every Linear issue labelled agent

In the Project that holds the app, add an automation with this prompt and a `linear` trigger on `linear.issue.labeled` filtered to the `agent` label. Each labelled front-end issue starts its own run in its own sandbox and ends in its own pull request; the issue text follows the prompt as data, and the trigger fills in no placeholder.

A handler on your own server does the same without the automation: it receives Linear's webhook, puts the issue text into `input`, and sends `POST /o/{org}/sessions` with the repository in `resources` and a `request_id` that is a UUID v5 of the issue id, so a redelivered webhook returns the run already started.

## Why run it on Rush?

Marking up every template is wide, mechanical work, and the check is a full localized build plus the unit and browser suites, which on a laptop means a Bun install, a Playwright browser download and several minutes per cycle. In a Rush sandbox the agent has Bun and a browser, runs the extraction, both builds and both suites itself, and keeps each run in the record.

A pull request that touches most templates is hard to review without evidence, and the transcript gives it: the extracted message count, the two output directories and the green suites. Several Angular apps can be internationalised at once, each in its own sandbox, each ending in its own pull request.

## Frequently asked questions

### Does the agent translate the strings?

No. It creates the `es` file from the extracted messages and fills each target with a placeholder marked for review, so a translator has one file to edit and the build already produces the second bundle. Say in the prompt if you want machine-drafted targets, and it will mark them as drafts.

### Why @angular/localize and not a runtime library?

The workspace already has an `extract-i18n` target, the app is built by `@angular/build:application`, and compile-time localization adds no runtime dependency or change detection cost in a zoneless app. If you need switching without a reload, say so and the agent uses a runtime library instead.

### What changes for deployment?

A localized production build writes one directory per locale under `dist/angular-conduit/browser`, so the deploy workflow's zip step and the `_redirects` asset need the locale prefix. The agent updates the workflow and names the change in the pull request; your host's routing for `/en/` and `/es/` is yours to set.

### Will my Vitest and Playwright suites break?

Vitest needs `@angular/localize/init` in `src/test-setup.ts` so `$localize` is defined, which the agent adds. Playwright specs read the source locale text and keep passing; specs that navigate by URL need the `/en/` prefix only if you point them at a localized build.

## More Angular jobs

- [Add a Not Found Page to an Angular App](https://getrush.ai/run/add-not-found-page/angular/)
- [Add Optimistic UI to an Angular App](https://getrush.ai/run/add-optimistic-ui/angular/)
- [Add Page Titles per Route to an Angular App](https://getrush.ai/run/add-page-titles/angular/)

## The same job on other stacks

- [Add a Second Language to an Astro Site](https://getrush.ai/run/add-i18n/astro/)
- [Add i18n to a Blazor Web App](https://getrush.ai/run/add-i18n/blazor/)
- [Add i18n to a Chrome Extension from a Linear Issue](https://getrush.ai/run/add-i18n/chrome-extension/)

## 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/)
