Documentation reviewed 23 November 2026.
Quick answer
Angular's built-in localization works at build time. You add @angular/localize, mark text with the i18n attribute in templates and with $localize in code, run ng extract-i18n to write a source file (XLIFF 1.2 by default), translate one copy of that file per language, list the files under i18n.locales in angular.json, and build with localize. The CLI then writes one complete copy of the app per locale, each in its own folder with its own lang attribute and base href. Changing language means loading another URL, not flipping a switch. If you need to switch language without a page load or without a rebuild, use a runtime library such as ngx-translate or Transloco, which load JSON files while the app runs.
Who this is for, and what you will have at the end
This guide targets Angular 22 (22.3.0 at the time of writing) and the default @angular/build:application builder. Angular 22 needs Node.js 22.22.3 or later, 24.15.0 or later, or 26. By the end you will have:
- Templates and component code marked for translation, with descriptions, meanings and stable ids where they help.
- Plurals and selects written as ICU expressions that translators can extend for their language.
- An extracted source file, one translation file per language, and a build that produces one app per locale.
- Dates, numbers and currency formatted by
LOCALE_ID, and a right to left layout. - A deployment layout that search engines can index: one URL per language,
lang, andhreflang. - Tests and a CI job that fail when a translation is missing or damaged.
- A way to check XLIFF that a model translated, and a view of when ngx-translate or Transloco fits better.

Part 1: add @angular/localize
From the project root:
The command adds the package, adds "types": ["@angular/localize"] to the TypeScript configuration files, and puts /// <reference types="@angular/localize" /> at the top of src/main.ts. By default the package goes into devDependencies, because translation happens during the build. Pass --use-at-runtime if you intend to call $localize with translations loaded at runtime. That moves it to dependencies.
If the package is missing and you build a localized app, the CLI stops with an error that lists the steps to enable i18n.
Part 2: mark the text
Text in templates
Add the i18n attribute to every element that holds fixed text:
The attribute value is metadata for the translator, in the form {meaning}|{description}@@{custom_id}. All three parts are optional.
| Part | What it does | Affects the generated id |
|---|---|---|
| Description | A note for the translator. | No |
| Meaning | Says which sense of the text is meant. Two identical texts with different meanings are extracted as two units. | Yes |
Custom id, after @@ | Replaces the generated id with a name you choose. | It is the id |
Three more points from the example:
- Attributes use
i18n-{attribute}:i18n-alt,i18n-title,i18n-placeholder,i18n-aria-label. The value takes the same metadata. <ng-container i18n>marks text without adding a DOM element.//i18n(ph="name")inside an interpolation names the placeholder. Without it the translator sees a generated name such asINTERPOLATION.
Text in component code
Strings that live in TypeScript use the $localize tagged template. The metadata sits between colons at the start, and a placeholder name sits between colons after the expression:
Generated ids or custom ids
By default Angular builds each unit's id from the source text and the meaning. When the text changes, the id changes, and the old translation no longer applies. That is usually what you want: a changed sentence needs a new translation.
A custom id stays the same when the text changes. The Angular documentation names the cost: the translation can go out of sync with the new source text, and two texts with the same custom id share one translation.
Use generated ids unless a tool or a workflow needs stable names. If you use custom ids, treat any edit to the English text as a task to re-translate that unit, and keep every id unique.
Part 3: plurals and selects
Angular templates accept ICU expressions with two clauses: plural and select.
The plural categories Angular documents are zero, one, two, few, many and other, plus exact matches such as =0 and =1. other is the fallback when no category matches. Clauses can be nested, for example a select inside the other branch of a plural.
English uses two categories. Other languages use more, and the translator adds or removes cases in the translation file. The categories per language come from the Unicode CLDR plural rules:
| Language | Cardinal categories |
|---|---|
| Japanese | other |
| English | one, other |
| French | one, many, other |
| Polish, Russian | one, few, many, other |
| Arabic | zero, one, two, few, many, other |

Put the whole sentence inside each branch. {{ count() }} {count(), plural, one {file} other {files}} deleted forces every language into English word order.Part 4: extract, and choose a file format
This writes src/locale/messages.xlf, the source language file. --format changes the format and --out-file changes the name.
--format | File | Fits |
|---|---|---|
xlf (default) | XLIFF 1.2, .xlf | The widest support among translation tools and agencies. The Angular documentation uses it throughout. |
xlf2 | XLIFF 2, .xlf | Tools that ask for XLIFF 2. Placeholders are <ph> and <pc> elements. |
xmb | XMB source, .xmb, with .xtb translation files | Toolchains built around XMB and XTB. |
json | A locale field and a translations map of id to text | Scripts and custom pipelines. Placeholders appear as {$NAME}. |
arb | Application Resource Bundle, .arb | Teams that already work with ARB tooling. |
A real unit from an XLIFF 1.2 extraction of the template above:
The interpolation became <x id="NAME"/>. An unnamed one is <x id="INTERPOLATION"/>. An inline link becomes a pair, <x id="START_LINK" ctype="x-a"/> and <x id="CLOSE_LINK" ctype="x-a"/>. In XLIFF 2 the same placeholder is <ph id="0" equiv="NAME" disp="..."/>.
A plural is extracted with the variable replaced by VAR_PLURAL:
When an ICU expression sits inside a longer sentence, Angular extracts two units: one for the sentence with an <x id="ICU"/> placeholder, and one for the expression itself.
Part 5: the translation file workflow
- Copy
messages.xlftomessages.{locale}.xlffor each language, for examplesrc/locale/messages.fr.xlf. - In each unit, add a
<target>next to the<source>and put the translation in it. - Leave every
idas it is. - For plurals, translate the text in each case and add or remove cases for the language.
Placeholders may move inside the sentence. They must not be removed. For the <x id="ICU"/> placeholder the documentation is explicit: remove it and the ICU expression is removed from the translated app.
The weak point of the documented workflow is step 1. Copying the source file works once. After the next extraction, the new and removed units have to be merged into every translation file by hand or by a tool. Part 11 covers that.
Part 6: configure locales and build
Declare the locales on the project, then tell the build to localize:
| Option | Values | Meaning |
|---|---|---|
i18n.sourceLocale | A locale id, default en-US, or an object with code, baseHref, subPath | The language the templates are written in. |
i18n.locales | A map of locale id to a file path, a list of paths, or an object with translation, baseHref, subPath | The translated locales and their files. |
localize | true, false, or a list of locale ids | Which locales this build produces. |
i18nMissingTranslation | warning (default), error, ignore | What a missing translation does to the build. |
subPath sets both the output folder and the base href for a locale. baseHref changes only the base href. They cannot be used together. If neither is set, both default to the locale id.
Then:
The development server localizes one locale at a time. With localize set to true or to more than one locale, ng serve logs a warning and turns localization off. Hence the fr configuration in the example.
What "one build per locale" means
The output for the configuration above:
Each folder is a complete app with its own bundles. The CLI compiles once and then applies the translations per locale, registers the locale data and sets LOCALE_ID. In the 22.3.0 test build for this guide, the generated index.html also carried dir="rtl" for Arabic and dir="ltr" for the others.
The consequences:
- A language switch is a link to another folder and a full page load.
- Fixing a typo in French means a rebuild and a deploy.
- Build output grows with each locale you add.
"i18nMissingTranslation": "error"catches a unit that is absent from a translation file. In the 22.3.0 test build, a unit that was present with no<target>passed the build, and the text in that unit's<source>was shipped. In a fresh copy ofmessages.xlfthat text is English, so an untranslated file builds without a warning. Check for empty targets yourself, as in Part 10.
Part 7: deploy, SSR and hydration
Static hosting
The server has two jobs: serve each locale folder with its own fallback to that folder's index.html, and decide what / returns. The Angular documentation ships Nginx and Apache examples that read the Accept-Language header and redirect / to a locale folder. Both assume every locale, the source one included, lives in a subfolder. If you serve the source locale from the root with "subPath": "", adapt them so only the other locales redirect.
Two details that are easy to miss with prerendered output (outputMode set to static):
- Nothing redirects by language. The host must do it.
- The CLI does not prerender a page for the
**wildcard route. Declare a real404route, let it prerender per locale, and point the host's error page at the one that matches the locale path.
Server rendering
With server rendering and outputMode set to server, Angular handles the redirect from the Accept-Language header itself, so the manual server rules are not needed.
Hydration
By default Angular skips hydration for components that contain i18n blocks and renders them again in the browser. To hydrate them, add withI18nSupport():
Part 8: dates, numbers, currency and LOCALE_ID
Four built-in pipes format by locale: DatePipe, CurrencyPipe, DecimalPipe and PercentPipe. They read the LOCALE_ID token, which a localized build sets for you.
The last line passes a locale as the final argument, which overrides LOCALE_ID for that one value. In a test run for this guide with the locale set to fr, the first two lines printed "23 novembre 2026" and "1 234,50 €".
Three facts to keep straight:
- Locale data.
ng build --localizeincludes the data for each locale automatically. Outside a localized build, for example when you provideLOCALE_IDyourself, import it:import '@angular/common/locales/global/fr';. - Reading the locale in code. Inject
LOCALE_IDin a component or service. Where injection is not available, read$localize.locale, which each localized build sets. - Currency is data. The pipe decides where the symbol and the separators go. Which currency the amount is in comes from your order, not from the locale.
Part 9: right to left
A right to left locale needs dir="rtl" on the <html> element. MDN recommends setting dir explicitly on the root element for every document. The Angular documentation mentions only the lang attribute, so confirm what your own build writes into index.html and set dir yourself if it is missing.
The rest is CSS and component code:
| Physical (does not mirror) | Logical (mirrors) |
|---|---|
margin-left | margin-inline-start |
padding-right | padding-inline-end |
left: 0 | inset-inline-start: 0 |
border-left | border-inline-start |
text-align: left | text-align: start |
Where a component must branch in code, for example to flip a custom drawn arrow, the Angular CDK has a Directionality service in its bidi package. Inject it and read value, which is 'rtl' or 'ltr'.
Put one right to left language and one long language, such as German, in the first batch. The layout fixes are the same for every language after that.
Part 10: when AI translates the XLIFF
A model drafts interface text well. XLIFF is where the draft breaks, because each unit mixes prose with markup that the build depends on.
| What breaks | Example | What the 22.3.0 test build did |
|---|---|---|
| A placeholder is dropped | <target>Bon retour</target> | Passed. The name is never shown. |
| ICU keywords are translated | {VAR_PLURAL, pluriel, =0 {...} autre {...}} | Passed. The raw text shipped as the message. |
| The English plural shape is copied | Only one and other in Polish | Passes. Wrong word for most numbers. |
<target> is left out | A unit with only <source> | Passed. The text in that unit's <source> shipped, which is English in an untouched copy. |
| A unit is removed | No unit for syncDone | Failed, with i18nMissingTranslation set to error. |
| An id is changed | id="syncDone" becomes id="syncTermine" | Same as a removed unit, plus one stale unit. |
| Select case names are translated | admin {...} becomes administrateur {...} | Passed. The renamed case no longer matches the value admin. |
Only two of those seven stopped the build, and both are the same failure: a unit the build could not find. A script has to catch the rest. This one compares every messages.*.xlf with the source file:
It reports missing units, empty targets, stale ids, a <source> that no longer matches the extraction (the sign of a custom id whose English changed), placeholders that were dropped or invented, ICU expressions that were flattened or renamed, and select cases that differ from the source. It does not know that Polish needs few and many. For that, test the boundary numbers of each language, or use a translation tool that checks categories against the CLDR rules. Automated localization QA lists which checks can run without a person.
When you prompt a model yourself, do not hand it the file. Send the text of each<source>with its description, with placeholders shown as tokens it is told to keep, and write the answers back into<target>by id. The ids, the notes and the XML structure then never pass through the model.

Part 11: tests and CI
Unit tests
Component tests run against the source language unless you load translations. loadTranslations from @angular/localize takes a map of id to text, in the same form as the JSON extraction format, and clearTranslations removes them. This test passed under ng test on Angular 22.3.0:
The Angular API documentation notes that $localize messages are processed once, when first encountered, so load translations before the component is created. For plural boundaries and layout, run end to end tests against the built locale folders, for example /pl/ with 1, 2, 5 and 22.
Keep the extracted files in sync
Two things drift: the source file falls behind the templates, and the translation files fall behind the source file.
For the first, extract in CI and fail when the committed file differs. For the second, run the check script or use ng-extract-i18n-merge, a community builder that replaces the extract-i18n target. Its README says it adds new units to every target file, removes deleted ones, manages translation states and normalizes the files so diffs stay readable. Version 3 supports Angular 20 and later and works with XLIFF 1.2 and 2. Install it with ng add ng-extract-i18n-merge, then keep running ng extract-i18n as before.
git diff --exit-code fails the job when extraction changed a committed file, which means someone edited a template without extracting. The build step fails on missing units because i18nMissingTranslation is error. If translation happens after merge, move the check script and the localized build to the release workflow. Localization as code covers that trade.
Part 12: SEO for a localized Angular app
The build per locale gives you the structure Google asks for: a different URL for each language version, not a cookie or a browser setting. What is left is yours to add.
lang. The build sets it on<html>per locale. Google states it does not uselangorhreflangto detect a page's language, which it works out from the visible content.langstill matters to browsers and screen readers.hreflang. Each language version must list itself and every other version, with fully qualified URLs.x-defaultnames the page for users whose language matches none.- No forced redirects on deep links. Google advises against automatically redirecting users from one language version to another. Redirect
/if you must, leave/fr/pricingalone, and show links to the other languages on every page.
The same set can go in the sitemap or in HTTP headers, which Google treats as equivalent methods. The sitemap is the simplest of the three for an Angular app, because index.html is shared by every route in a locale. Translate the <title> and the meta description as well: mark the strings with $localize where you set them.
Built-in i18n, ngx-translate or Transloco, by fit
Built-in i18n translates at build time. The two widely used alternatives translate at runtime from JSON files.
ngx-translate. Version 18 of @ngx-translate/core requires Angular 18 or newer. You register it with provideTranslateService, load files with @ngx-translate/http-loader, and translate with a pipe or a directive:
The JSON value is "Hello {{name}}!". TranslateService.use('fr') switches language and loads the file if needed. ICU plurals are not part of the core pages read for this guide. The separate package ngx-translate-messageformat-compiler adds them.
Transloco. @jsverse/transloco is configured with provideTransloco (availableLangs, defaultLang, reRenderOnLangChange, prodMode, a loader class). Its documentation recommends the structural directive:
setActiveLang('es') switches language. ICU plurals come from the @jsverse/transloco-messageformat plugin. At the time of writing the Transloco documentation describes version 9, installed with the @next tag, while the latest tag on npm is 8.4.0. Its server rendering page says the loader needs an absolute URL on the server, and describes itself as out of date with current Angular SSR.
Built-in @angular/localize | ngx-translate | Transloco | |
|---|---|---|---|
| When text is translated | At build time | At runtime | At runtime |
| Files | XLIFF 1.2 or 2, XMB, JSON, ARB | JSON, keys you name | JSON, keys you name |
| Switch language | Load another URL | use('fr'), no reload | setActiveLang('fr'), no reload |
| Fix a translation | Rebuild and deploy | Replace a JSON file | Replace a JSON file |
| Plurals | ICU plural and select in the template | Through a separate compiler package | Through the messageformat plugin |
| One URL per language | Yes, from the build | You add the routing | You add the routing |
| Build-time check for missing text | Yes, i18nMissingTranslation | None in the pages read | None in the pages read |
| Fits | Content sites, apps where SEO and first paint matter, teams with translators who use XLIFF tools | Apps behind a login that need an in-app language menu, existing ngx-translate codebases | The same need, for teams that prefer the structural directive and the messageformat plugin |
Two questions settle it. Must the app change language without a page load, or change text without a deploy? Use a runtime library. Does each language need its own indexable URL with the text already in the HTML? Use the built-in build per locale. Neither runtime library was benchmarked for this guide. If you choose JSON files, translating JSON i18n files with AI covers the checks for that format.
Doing this with Transglot
Transglot is a continuous localization platform. Glossa, its translation engine, translates the strings that changed, and four checks run on every string before it is written: placeholders, plural forms, glossary terms and length. For Angular the fit depends on which path you chose above, and the limits are specific.
With built-in i18n and XLIFF, the support is partial. Transglot reads and writes XLIFF 1.2 as xliff_12 and XLIFF 2.0 as xliff_20. Its XLIFF format page states these limits:
- A unit whose source or target contains inline elements (
<x/>,<g>,<ph>,<pc>and the others) is skipped with a warning. Transglot stores plain text and will not import a unit with its placeholders removed. In an Angular file that is every unit with an interpolation or an inline tag. - Neither XLIFF version has a plural construct in Transglot. Plural keys are left out of an XLIFF export, and an ICU plural message inside a unit is treated as an ordinary string.
- In XLIFF 2.0, units inside
<group>elements are not imported and notes are not carried in. In 1.2,<note>elements become the key's description. - An export contains only translated keys, so the skipped units are absent from it. With
i18nMissingTranslationset toerror, an Angular build from that file alone fails.
So for built-in i18n, Transglot today covers the plain text units and not the rest. In a test for this guide, Angular 22.3.0 built a locale from a hand-written file in the documented export shape. The round trip through Transglot itself was not run. If most of your strings carry interpolations, use an XLIFF tool that keeps inline elements, with the check script from Part 10.
With ngx-translate or Transloco, the files are JSON. Transglot reads them as json_nested or json_flat, and its checks recognize double brace placeholders such as {{name}}. With Node.js 22 or later:
init signs in through the browser, runs the first translation and writes transglot.json:
After that, transglot push --wait uploads changed strings and waits for the translation, and transglot pull writes the target files. The GitHub Action runs the same round trip on every push to main. JSON has no plural construct of its own, so plural keys are not exported to it. The Transglot file formats page says an ICU message inside a string is stored as an ordinary string and written back unchanged.
There is also a runtime package. @transglot/angular is for Angular 17 and later: provideTransglot, a TransglotService with a locale signal and setLocale, and a standalone translate pipe. It loads published translations from the Transglot CDN, so a fixed string reaches users without a build. Its documented limits: no server rendering, and translations return the key until the bundle arrives. It replaces a runtime library. It does not add to built-in i18n.
The command line, the GitHub Action, the API and runtime delivery start on the Starter plan, at $19 a month for 300,000 translated words. The Free plan works in the browser console. Transglot is not self-hostable. See pricing and the quickstart.
Common mistakes
- Expecting a language switch at runtime. Built-in i18n produces one app per locale. Decide this before you mark a thousand strings.
- Running
ng servewith every locale. The dev server handles one. Add a configuration per locale you develop against. - Trusting
i18nMissingTranslationalone. It catches absent units. Check empty targets and placeholders yourself. - Custom ids without discipline. The text changes, the id does not, and the old translation ships.
- Building sentences from fragments. Two marked spans and a variable cannot be reordered by a translator.
- Copying the English plural shape.
oneandotherare not enough for Polish or Arabic. - Left and right in CSS. Use logical properties.
- No
hreflang. The build makes the URLs. It does not tell search engines how they relate.
Checklist
Frequently asked questions
How do I add i18n to an Angular app?
Run ng add @angular/localize, mark template text with the i18n attribute and code strings with $localize, then run ng extract-i18n to create messages.xlf. Copy it once per language, add a <target> to each unit, list the files under i18n.locales in angular.json, and build with ng build --localize.
Can Angular switch language at runtime without reloading?
Not with the built-in i18n. It builds one copy of the app per locale, and changing language means loading that locale's URL. For a switch without a reload, use a runtime library such as ngx-translate or Transloco.
What is the difference between ngx-translate and Angular i18n?
Angular i18n replaces text at build time and produces one app per language, with translations in XLIFF, XMB, JSON or ARB files. ngx-translate loads JSON files at runtime and looks keys up with a pipe, a directive or a service, so one build serves every language.
What is Transloco?
Transloco is a runtime translation library for Angular, published as @jsverse/transloco. It loads JSON files, translates through a structural directive, a pipe or an attribute directive, and switches language with setActiveLang.
What file format does ng extract-i18n produce?
XLIFF 1.2 by default, in a file named messages.xlf. The --format option also accepts xlf2 for XLIFF 2, xmb, json and arb.
How do plurals work in Angular i18n?
You write an ICU expression in the template, for example {count, plural, =0 {none} one {one item} other {{{count}} items}}. It is extracted as one unit, and the translator adds or removes cases for the language. other is the fallback.
How do I fail the build when a translation is missing?
Set "i18nMissingTranslation": "error" in the build options in angular.json. The default is warning. In the test for this guide it failed on a unit missing from the file and did not fail on a unit with no <target>. Add a script check for empty targets.
Can I translate Angular XLIFF files with AI?
Yes, with checks. A model can drop <x id="INTERPOLATION"/> placeholders, translate ICU keywords or leave out a <target>, and the Angular build accepted all three in testing. Compare placeholders, ICU structure and targets against the source file before you build.
How this guide was checked
- Setup, marking text, metadata, ICU expressions, extraction formats, the translation file workflow,
angular.jsonoptions, building, missing translation levels, deployment, prerendering, custom ids, pipes,LOCALE_IDand locale data follow the Angular i18n guide pages listed under Sources, read in the Angular documentation source for the pages served at angular.dev. Option names and defaults were also read in the Angular CLI builder schemas. - Hydration follows the Angular hydration guide.
loadTranslationsfollows the API documentation in the@angular/localizesource. - A new Angular 22.3.0 project was created for this guide. The template, the
$localizecall, the extraction, theangular.jsonfragment, a localized build with French, Polish and Arabic, the unit test andtools/check-xlf.mjswere run in it. The XML samples are from that extraction, and the build behaviors in Parts 6 and 10 were observed there, including thedirattribute, which the documentation does not mention. - Not tested: the Nginx and Apache configurations, server rendering, hydration with
withI18nSupport(), the GitHub Actions workflow, ng-extract-i18n-merge (read on its README, not run), and XLIFF 2 with the check script, which reads XLIFF 1.2 only. - ngx-translate and Transloco were read on their own documentation sites. Their snippets follow those pages and were not compiled. Neither library was benchmarked, so this guide makes no claim about which performs better.
- Plural categories follow the Unicode CLDR plural rules chart.
hreflangand URL rules follow Google Search Central.dirand logical properties follow MDN. - Transglot statements follow the Transglot documentation. No Angular XLIFF file was imported into Transglot for this guide.
Sources
- Angular: Internationalization overview
- Angular: Add the localize package
- Angular: Refer to locales by ID
- Angular: Format data based on locale
- Angular: Prepare component for translation
- Angular: Work with translation files
- Angular: Merge translations into the application
- Angular: Deploy multiple locales
- Angular: Import global variants of the locale data
- Angular: Manage marked text with custom IDs
- Angular: Workspace configuration, i18n options
- Angular: Hydration
- Angular: Version compatibility
- Angular documentation source for the i18n guide
- Angular source: loadTranslations
- Angular CLI source: extract-i18n builder schema
- Angular CDK: bidi
- Unicode CLDR: language plural rules
- Google Search Central: localized versions of your pages
- Google Search Central: managing multi-regional and multilingual sites
- MDN: the dir global attribute
- MDN: CSS logical properties and values
- ngx-translate: installation
- ngx-translate: translating your components
- ngx-translate: TranslateService API
- ngx-translate-messageformat-compiler
- Transloco: installation
- Transloco: translation in the template
- Transloco: language API
- Transloco: message format plugin
- Transloco: SSR support
- ng-extract-i18n-merge
- Transglot: XLIFF format
- Transglot: file formats
- Transglot: Angular runtime SDK
- Transglot: runtime SDKs
- Transglot: quality checks
- Transglot quickstart
- Transglot pricing