Internationalization
Angular's built-in $localize/locale-build i18n pipeline, versus runtime translation libraries like ngx-translate and Transloco.
Interpolation and property, attribute, class, and style binding
Internationalization
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- Angular's built-in i18n pipeline marks translatable text with $localize and i18n template attributes, then produces a separate, fully-compiled build per locale — translation happens at build time, not runtime.
- A runtime library like ngx-translate or Transloco instead loads translation files at runtime and swaps text on the fly — one single build serves every language, with no per-locale rebuild needed.
- The real tradeoff is build-time performance (built-in i18n, no runtime overhead, but a locale switch means loading a different build) versus runtime flexibility (a translation library, one build, but a small runtime cost and a translation key to manage for every piece of text).
Two genuinely different approaches, not one obvious default
Supporting multiple languages means solving the same underlying problem — mapping displayed text to the user’s chosen language — but Angular offers two structurally different ways to solve it, and neither is simply “the modern one.” They trade off build complexity against runtime flexibility in opposite directions, and the right choice genuinely depends on what your app needs.
Angular’s built-in pipeline: translate at build time
<h1 i18n="@@welcomeHeading">Welcome back!</h1>
<p i18n>You have {count, plural, one {one message} other {{{count}} messages}}</p>
console.log($localize`Loading, please wait…`);
The i18n attribute marks a template element’s text as translatable; $localize
does the same for strings in TypeScript code. A separate extraction step pulls
every marked string out into a translation source file, translators (or a
translation service) fill in each target language’s version, and — this is the
defining characteristic — Angular’s build process then produces a complete,
separate compiled build for each locale, with the translated text baked
directly into that locale’s bundle. There’s no translation lookup happening at
runtime at all; by the time a build ships, it’s already entirely in one
specific language.
Runtime libraries: one build, translations loaded on demand
<h1>{{ 'welcome.heading' | translate }}</h1>
A library like ngx-translate or Transloco takes the opposite approach: instead
of baking a specific language into the build, every piece of translatable text
is referenced by a key ('welcome.heading'), and the actual translated string
is loaded — typically from a JSON file — at runtime, then displayed through a
pipe or directive. One single build serves every supported language; switching
languages means loading a different translation file, not loading a different
build.
The actual tradeoff, not just a feature comparison
The built-in pipeline’s build-time approach means zero runtime translation overhead — no lookup, no loaded translation file, nothing extra happening while the app runs — at the cost of needing a genuinely separate build artifact per locale, which has real implications for deploy pipelines and for how easily a user can switch languages without navigating to an entirely different build. A runtime library’s single-build simplicity costs a small, usually negligible runtime overhead and asks you to manage translation keys consistently across your codebase, in exchange for adding or switching languages without touching the build process at all. Teams supporting a handful of stable languages with infrequent additions often lean toward the built-in pipeline for its performance; teams needing to add languages frequently, or wanting instant in-app language switching, more often reach for a runtime library instead.
Beyond translated strings: locale-aware formatting
Internationalization isn’t only about swapping text between languages — dates,
numbers, and currencies format differently across locales even when the
surrounding language stays the same (1,234.56 versus 1.234,56, or a date
ordered month-day-year versus day-month-year). Angular’s built-in date,
currency, and number pipes — covered earlier in this roadmap — already
read the active locale to format accordingly, independent of which of the two
translation approaches above you choose for the surrounding text. This is
worth keeping separate in your head from the i18n-versus-runtime-library
decision: locale-aware formatting is handled either way, by the same pipes,
regardless of how the translatable strings themselves get resolved.
This lesson’s video covers the built-in pipeline in a thorough, current, company-produced guide; the two linked videos round this out — the official Angular team’s own introduction to the built-in approach, and a dedicated walkthrough of the Transloco runtime-library alternative, giving you both sides of the tradeoff directly rather than just this lesson’s description of it.
Check yourself
With Angular's built-in i18n pipeline, if you want to add a 10th supported language to an app that already supports 9, what does your build process now need to do that it didn't before?
Produce an additional, fully separate compiled build specifically for that 10th locale — the built-in pipeline generates one complete build per locale at build time, so adding a language means adding another entire build artifact, not just another translation file loaded at runtime.
Why might a team ship a runtime translation library like Transloco instead of Angular's built-in i18n, even knowing it adds a small runtime cost?
A runtime library needs exactly one build to serve every supported language — switching languages (or adding a new one) means loading a different translation file, not rebuilding and redeploying the entire app. For a product that needs to add languages frequently, or let users switch language without a full page reload pointing at a different build, that operational simplicity can outweigh the built-in pipeline's build-time performance advantage.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.