Skip to content

Optional analytics, session recording and advertising stay off unless you accept. You can reject them and use Transglot. Change your choice anytime in Cookie preferences. Cookie Policy

Back to the blog
Developer platform

Angular Localization: The Complete i18n Guide (2026)

Angular i18n end to end: marking text, XLIFF files, one build per locale, pipes, right to left, SSR, SEO, CI, and ngx-translate or Transloco by fit.

by transglot team
published November 23, 2026
25 min read

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, and hreflang.
  • 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.
A cream paper-pulp printing press on a stone plinth pressing one master sheet into four separate stacks of pages
One source file, one translation file per language, one build per locale

Part 1: add @angular/localize

From the project root:

Angular CLI 22bash
ng add @angular/localize

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:

src/app/app.htmlhtml
<h1 i18n="site header|Title of the inbox page@@inboxTitle">Inbox</h1>
<p i18n="Greeting above the message list">
Welcome back, {{ name() //i18n(ph="name") }}
</p>
<img src="logo.svg" i18n-alt="Alt text of the product logo" alt="Parcel Tracker logo" />
<ng-container i18n>No element is created for this sentence.</ng-container>

The attribute value is metadata for the translator, in the form {meaning}|{description}@@{custom_id}. All three parts are optional.

PartWhat it doesAffects the generated id
DescriptionA note for the translator.No
MeaningSays 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 as INTERPOLATION.

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:

tsts
status = $localize`:Status line after a sync@@syncDone:Synced ${this.count()}:count: messages`;

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.
Rule

Part 3: plurals and selects

Angular templates accept ICU expressions with two clauses: plural and select.

htmlhtml
<p i18n="Badge on the inbox tab">
{count(), plural, =0 {No new messages} one {One new message} other {{{ count() }} new messages}}
</p>
<p i18n>{role(), select, admin {Administrator} editor {Editor} other {Viewer}}</p>

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:

LanguageCardinal categories
Japaneseother
Englishone, other
Frenchone, many, other
Polish, Russianone, few, many, other
Arabiczero, one, two, few, many, other
A stepped row of cream paper-pulp tiles on a stone plinth, two tiles on the left and six on the right
English fills two plural categories. Arabic fills six.
Put the whole sentence inside each branch. {{ count() }} {count(), plural, one {file} other {files}} deleted forces every language into English word order.
Rule

Part 4: extract, and choose a file format

bashbash
ng extract-i18n --output-path src/locale

This writes src/locale/messages.xlf, the source language file. --format changes the format and --out-file changes the name.

--formatFileFits
xlf (default)XLIFF 1.2, .xlfThe widest support among translation tools and agencies. The Angular documentation uses it throughout.
xlf2XLIFF 2, .xlfTools that ask for XLIFF 2. Placeholders are <ph> and <pc> elements.
xmbXMB source, .xmb, with .xtb translation filesToolchains built around XMB and XTB.
jsonA locale field and a translations map of id to textScripts and custom pipelines. Placeholders appear as {$NAME}.
arbApplication Resource Bundle, .arbTeams that already work with ARB tooling.

A real unit from an XLIFF 1.2 extraction of the template above:

src/locale/messages.xlf, extracted with Angular 22.3.0xml
<trans-unit id="6278227525020690453" datatype="html">
<source>Welcome back, <x id="NAME" equiv-text="{{ name() //i18n(ph=&quot;name&quot;) }}"/></source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/app.html</context>
<context context-type="linenumber">2,3</context>
</context-group>
<note priority="1" from="description">Greeting above the message list</note>
</trans-unit>

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:

xmlxml
<source>{VAR_PLURAL, plural, =0 {No new messages} one {One new message} other {<x id="INTERPOLATION"/> new messages}}</source>

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

  1. Copy messages.xlf to messages.{locale}.xlf for each language, for example src/locale/messages.fr.xlf.
  2. In each unit, add a <target> next to the <source> and put the translation in it.
  3. Leave every id as it is.
  4. For plurals, translate the text in each case and add or remove cases for the language.
src/locale/messages.pl.xlfxml
<trans-unit id="3321605595766383933" datatype="html">
<source>{VAR_PLURAL, plural, =0 {No new messages} one {One new message} other {<x id="INTERPOLATION"/> new messages}}</source>
<target>{VAR_PLURAL, plural, =0 {Brak nowych wiadomości} one {<x id="INTERPOLATION"/> nowa wiadomość} few {<x id="INTERPOLATION"/> nowe wiadomości} many {<x id="INTERPOLATION"/> nowych wiadomości} other {<x id="INTERPOLATION"/> wiadomości}}</target>
</trans-unit>

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:

angular.json, only the i18n partsjson
{
"projects": {
"parcel-tracker": {
"i18n": {
"sourceLocale": { "code": "en", "subPath": "" },
"locales": {
"fr": "src/locale/messages.fr.xlf",
"pl": "src/locale/messages.pl.xlf",
"ar": "src/locale/messages.ar.xlf"
}
},
"architect": {
"build": {
"builder": "@angular/build:application",
"options": {
"localize": true,
"i18nMissingTranslation": "error"
},
"configurations": {
"development": { "localize": false },
"fr": { "localize": ["fr"] }
}
},
"serve": {
"configurations": {
"fr": { "buildTarget": "parcel-tracker:build:development,fr" }
}
}
}
}
}
}
OptionValuesMeaning
i18n.sourceLocaleA locale id, default en-US, or an object with code, baseHref, subPathThe language the templates are written in.
i18n.localesA map of locale id to a file path, a list of paths, or an object with translation, baseHref, subPathThe translated locales and their files.
localizetrue, false, or a list of locale idsWhich locales this build produces.
i18nMissingTranslationwarning (default), error, ignoreWhat 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:

bashbash
ng build --localize # every locale, same as "localize": true
ng serve --configuration=fr # the dev server, one locale
ng build --configuration=production,fr

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:

texttext
dist/parcel-tracker/browser/
├── index.html lang="en" <base href="/">
├── fr/index.html lang="fr" <base href="/fr/">
├── pl/index.html lang="pl" <base href="/pl/">
└── ar/index.html lang="ar" <base href="/ar/">

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 of messages.xlf that text is English, so an untranslated file builds without a warning. Check for empty targets yourself, as in Part 10.
Watch out

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 real 404 route, 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():

src/app/app.config.tsts
import { provideClientHydration, withI18nSupport } from '@angular/platform-browser';
export const appConfig = {
providers: [provideClientHydration(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.

htmlhtml
<p>{{ today | date: 'longDate' }}</p>
<p>{{ total | currency: 'EUR' }}</p>
<p>{{ ratio | percent }}</p>
<p>{{ amount | currency: 'USD' : 'symbol' : '1.2-2' : 'en-US' }}</p>

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 --localize includes the data for each locale automatically. Outside a localized build, for example when you provide LOCALE_ID yourself, import it: import '@angular/common/locales/global/fr';.
  • Reading the locale in code. Inject LOCALE_ID in 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-leftmargin-inline-start
padding-rightpadding-inline-end
left: 0inset-inline-start: 0
border-leftborder-inline-start
text-align: lefttext-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.
In short

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 breaksExampleWhat 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 copiedOnly one and other in PolishPasses. Wrong word for most numbers.
<target> is left outA unit with only <source>Passed. The text in that unit's <source> shipped, which is English in an untouched copy.
A unit is removedNo unit for syncDoneFailed, with i18nMissingTranslation set to error.
An id is changedid="syncDone" becomes id="syncTermine"Same as a removed unit, plus one stale unit.
Select case names are translatedadmin {...} 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:

tools/check-xlf.mjs, for XLIFF 1.2, run with: node tools/check-xlf.mjsjs
import {readFileSync, readdirSync} from 'node:fs';
import {join} from 'node:path';
const dir = process.argv[2] ?? 'src/locale';
const sourceName = 'messages.xlf';
function units(path) {
const xml = readFileSync(path, 'utf8');
const map = new Map();
for (const [, id, body] of xml.matchAll(/<trans-unit\b[^>]*\bid="([^"]+)"[^>]*>([\s\S]*?)<\/trans-unit>/g)) {
const pick = (tag) => body.match(new RegExp(`<${tag}\\b[^>]*>([\\s\\S]*?)</${tag}>`))?.[1];
map.set(id, {source: pick('source') ?? '', target: pick('target')});
}
return map;
}
const placeholders = (text) => [...new Set([...text.matchAll(/<x\b[^>]*\bid="([^"]+)"/g)].map((m) => m[1]))].sort().join(' ');
const icuHeads = (text) => [...text.matchAll(/\{\s*(VAR_[A-Z_0-9]+)\s*,\s*(plural|select)\s*,/g)].map((m) => `${m[1]},${m[2]}`).sort().join(' ');
const selectCases = (text) =>
[...text.matchAll(/\{\s*VAR_SELECT[A-Z_0-9]*\s*,\s*select\s*,((?:[^{}]|\{[^{}]*\})*)\}/g)]
.map((m) => [...m[1].matchAll(/([^\s{}]+)\s*\{/g)].map((c) => c[1]).sort().join(','))
.join(' | ');
const source = units(join(dir, sourceName));
const problems = [];
for (const name of readdirSync(dir)) {
if (!/^messages\..+\.xlf$/.test(name)) continue;
const target = units(join(dir, name));
for (const id of target.keys()) {
if (!source.has(id)) problems.push(`${name}: unit ${id} is not in ${sourceName} (stale or renamed id)`);
}
for (const [id, unit] of source) {
const translated = target.get(id);
if (!translated) { problems.push(`${name}: unit ${id} is missing`); continue; }
if (!translated.target?.trim()) { problems.push(`${name}: unit ${id} has no <target>`); continue; }
if (translated.source.trim() !== unit.source.trim()) problems.push(`${name}: unit ${id} has a <source> that differs from ${sourceName}`);
if (placeholders(translated.target) !== placeholders(unit.source)) {
problems.push(`${name}: unit ${id} placeholders differ: expected [${placeholders(unit.source)}], found [${placeholders(translated.target)}]`);
}
if (icuHeads(translated.target) !== icuHeads(unit.source)) {
problems.push(`${name}: unit ${id} lost or changed an ICU expression`);
} else if (selectCases(translated.target) !== selectCases(unit.source)) {
problems.push(`${name}: unit ${id} select cases differ from the source`);
}
if (/,\s*plural\s*,/.test(translated.target) && !/\bother\s*\{/.test(translated.target)) {
problems.push(`${name}: unit ${id} plural has no "other" case`);
}
}
}
for (const line of problems) console.error(line);
process.exit(problems.length ? 1 : 0);

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.
Rule
A cream paper-pulp gate with narrow slots on a stone plinth, small paper cards passing through and one card set aside
The build stops one kind of damage. A script has to stop the rest.

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:

src/app/app.spec.tsts
import '@angular/common/locales/global/fr';
import {LOCALE_ID} from '@angular/core';
import {TestBed} from '@angular/core/testing';
import {clearTranslations, loadTranslations} from '@angular/localize';
import {provideRouter} from '@angular/router';
import {App} from './app';
describe('App in French', () => {
beforeEach(() => {
loadTranslations({
inboxTitle: 'Boîte de réception',
syncDone: '{$count} messages synchronisés',
});
TestBed.configureTestingModule({
imports: [App],
providers: [provideRouter([]), {provide: LOCALE_ID, useValue: 'fr'}],
});
});
afterEach(() => clearTranslations());
it('formats dates and money for the locale', async () => {
const fixture = TestBed.createComponent(App);
await fixture.whenStable();
const text = (fixture.nativeElement as HTMLElement).textContent ?? '';
expect(text).toContain('23 novembre 2026');
expect(text).toMatch(/1\s234,50\s€/);
});
it('uses the loaded translations', async () => {
const fixture = TestBed.createComponent(App);
await fixture.whenStable();
const el = fixture.nativeElement as HTMLElement;
expect(el.querySelector('h1')?.textContent).toBe('Boîte de réception');
expect(el.textContent).toContain('3 messages synchronisés');
});
});

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.

.github/workflows/i18n.ymlyaml
name: i18n
on: [pull_request]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
- run: npm ci
- run: npx ng extract-i18n --output-path src/locale
- run: git diff --exit-code src/locale
- run: node tools/check-xlf.mjs
- run: npx ng build --localize
- run: npx ng test --watch=false

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 use lang or hreflang to detect a page's language, which it works out from the visible content. lang still matters to browsers and screen readers.
  • hreflang. Each language version must list itself and every other version, with fully qualified URLs. x-default names 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/pricing alone, and show links to the other languages on every page.
htmlhtml
<link rel="alternate" hreflang="en" href="https://example.com/pricing" />
<link rel="alternate" hreflang="fr" href="https://example.com/fr/pricing" />
<link rel="alternate" hreflang="pl" href="https://example.com/pl/pricing" />
<link rel="alternate" hreflang="x-default" href="https://example.com/pricing" />

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:

providers in app.config.ts, after the ngx-translate v18 installation pagets
provideHttpClient(),
provideTranslateService({
loader: provideTranslateHttpLoader({ prefix: '/assets/i18n/', suffix: '.json' }),
fallbackLang: 'en',
lang: 'en',
}),
htmlhtml
<p>{{ 'app.hello' | translate: { name: userName } }}</p>

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:

htmlhtml
<ng-container *transloco="let t">
<p>{{ t('title') }}</p>
</ng-container>

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/localizengx-translateTransloco
When text is translatedAt build timeAt runtimeAt runtime
FilesXLIFF 1.2 or 2, XMB, JSON, ARBJSON, keys you nameJSON, keys you name
Switch languageLoad another URLuse('fr'), no reloadsetActiveLang('fr'), no reload
Fix a translationRebuild and deployReplace a JSON fileReplace a JSON file
PluralsICU plural and select in the templateThrough a separate compiler packageThrough the messageformat plugin
One URL per languageYes, from the buildYou add the routingYou add the routing
Build-time check for missing textYes, i18nMissingTranslationNone in the pages readNone in the pages read
FitsContent sites, apps where SEO and first paint matter, teams with translators who use XLIFF toolsApps behind a login that need an in-app language menu, existing ngx-translate codebasesThe 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 i18nMissingTranslation set to error, 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:

bashbash
npx transglot@latest init --targets fr,pl,ar

init signs in through the browser, runs the first translation and writes transglot.json:

transglot.json, for JSON files served from public/i18njson
{
"url": "https://api.transglot.ai",
"sources": [
{ "path": "public/i18n/{locale}.json", "format": "json_nested", "locales": ["en"] }
],
"pull": [
{ "path": "public/i18n/{locale}.json", "format": "json_nested", "locales": ["fr", "pl", "ar"] }
]
}

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 serve with every locale. The dev server handles one. Add a configuration per locale you develop against.
  • Trusting i18nMissingTranslation alone. 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. one and other are 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

texttext
[ ] @angular/localize added with ng add
[ ] Every user-facing string marked with i18n, i18n-attr or $localize
[ ] Descriptions on short or ambiguous strings; meanings where one word has two senses
[ ] Plurals and selects are ICU expressions with whole sentences per branch
[ ] ng extract-i18n writes to src/locale; one messages.{locale}.xlf per language
[ ] i18n.sourceLocale and i18n.locales set in angular.json
[ ] localize on for production, one locale per serve configuration
[ ] i18nMissingTranslation set to error
[ ] Dates, numbers and currency go through the pipes
[ ] dir checked in each built index.html; CSS uses logical properties
[ ] Server serves each locale folder; / redirect and 404 pages decided
[ ] withI18nSupport() added if the app hydrates
[ ] hreflang set for every page, with x-default
[ ] check-xlf.mjs, extraction diff and localized build run in CI
[ ] Plural boundaries tested for the language with the most forms

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.json options, building, missing translation levels, deployment, prerendering, custom ids, pipes, LOCALE_ID and 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. loadTranslations follows the API documentation in the @angular/localize source.
  • A new Angular 22.3.0 project was created for this guide. The template, the $localize call, the extraction, the angular.json fragment, a localized build with French, Polish and Arabic, the unit test and tools/check-xlf.mjs were run in it. The XML samples are from that extraction, and the build behaviors in Parts 6 and 10 were observed there, including the dir attribute, 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. hreflang and URL rules follow Google Search Central. dir and logical properties follow MDN.
  • Transglot statements follow the Transglot documentation. No Angular XLIFF file was imported into Transglot for this guide.

Sources

colophon

Who wrote this, and what to read next

wrote this

transglot team

The byline on this post has no profile yet. Author profiles are managed alongside the posts themselves.

Engineering
keep reading

Localization as code: automate translations in CI/CD

Connect localization to CI/CD with scoped tokens, explicit waiting, reviewed translation snapshots and a recovery path for failed or partial runs.

February 24, 2026
7 min read
keep reading

Automated localization QA with Transglot

Catch broken placeholders, incomplete plurals and terminology conflicts. Learn what automated QA proves, where human review matters and how to validate a release.

March 31, 2026
6 min read
keep reading

How to Translate JSON i18n Files with AI

Three ways to translate a JSON locale file with AI, what breaks when you paste it into a chatbot, and the checks that keep keys, placeholders and plurals intact.

November 23, 2026
8 min read
works with what you already run

41 connectors, already built.

the pipeline this post describes

Try it on your own strings. Free, no card.

Free plan: 100,000 words to start (25,000 at sign-up, 75,000 after a phone check), then 10,000 a month, 15 locales including your source, 3 seats.