このページとあなたの好きなAIアシスタントを使ってドキュメントを要約します
このページのコンテンツはAIを使用して翻訳されました。
英語の元のコンテンツの最新バージョンを見るこのドキュメントを改善するアイデアがある場合は、GitHubでプルリクエストを送信することで自由に貢献してください。
ドキュメントへのGitHubリンクドキュメントのMarkdownをクリップボードにコピー
ngx-translate vs Angular i18n vs Transloco vs Intlayer
Angular is the only major framework that ships its own i18n, and it takes the opposite approach from the libraries the community built around it. @angular/localize translates at build time and produces one app per language. ngx-translate and Transloco translate at runtime from JSON files. Intlayer compiles content at build time but keeps a single app that switches language at runtime.
This post compares the four on what decides the choice in practice: how the locale switches, where the content lives, what the compiler catches, and what loads in the browser.
Table of Contents
The short version
@angular/localize(Angular i18n): zero runtime cost and native ICU, but one build and one deployment per locale, and switching language reloads the app.ngx-translate: the oldest and simplest runtime option. One JSON file per locale loaded over HTTP, untyped keys, plurals through a plugin.- Transloco: the runtime option built for larger apps. Scopes load translations per feature, and a plugin ecosystem covers ICU, locale formatting and key extraction.
- Intlayer: content declared next to each component, typed at build time, split per component and per locale, with runtime switching. Requires a custom esbuild builder.
To see where each library comes from, read the history of JavaScript i18n.
Build-time or runtime: the decision that splits the field
@angular/localize inlines translations into the compiled templates. ng build --localize outputs dist/app/en, dist/app/fr and so on, each one containing only its own language. Nothing is fetched and nothing is interpreted at runtime, which makes it the fastest option once loaded. The cost is operational: N builds to test, N folders to deploy, a server or CDN rule to route /fr/ to the right one, and a full page load when the user changes language. ng serve also runs a single locale at a time.
ngx-translate and Transloco keep one build. A service fetches fr.json when the locale changes and every pipe or directive re-renders. Switching is instant, but the first render waits for the HTTP request, keys are plain strings, and with SSR the loader must work on the server too (absolute URLs or a file-system loader, plus TransferState to avoid fetching twice).
Intlayer also keeps one build, but content is compiled into the bundle rather than fetched as a raw JSON file. useIntlayer() returns a Signal, so a locale change updates the components that read it, without reload.
One Angular detail is easy to miss with runtime libraries: DatePipe, CurrencyPipe and DecimalPipe read LOCALE_ID, which is fixed at bootstrap. Switching language with ngx-translate does not change how dates and prices are formatted. Transloco solves it with @jsverse/transloco-locale, Intlayer with useDate, useNumber and useCurrency that follow the active locale. @angular/localize does not have the problem, since each build has its own LOCALE_ID. The date, time and number formatting guide covers the Intl side.
Feature comparison
テーブルをモーダルで開き、すべてのデータを明確に表示
@angular/localize | ngx-translate | Transloco | Intlayer | |
|---|---|---|---|---|
| Translation applied | Build time, inlined | Runtime | Runtime | Build time compiled, resolved at runtime |
| Builds per release | One per locale | One | One | One |
| Locale switch | Page reload to another build | Instant | Instant | Instant |
| Where content lives | Source text in templates, translations in XLIFF/JSON | One JSON per locale | One JSON per locale, plus one per scope | .content.ts (or JSON) next to each component, or centralized |
| Plurals / ICU | ✅ Native ICU in templates | ⚠️ Plugin (ngx-translate-messageformat-compiler) | ⚠️ Plugin (@jsverse/transloco-messageformat) | ✅ plural() with CLDR rules, ⚠️ ICU strings partial |
| Typed keys | Not applicable, the source text is the message | ❌ No | ❌ No, Keys Manager finds missing keys from the CLI | ✅ Generated, a wrong key fails ng build |
| Missing translations | Build warning, or error with i18nMissingTranslation | Shows the raw key at runtime | Fallback language at runtime, CLI check | Flagged by TypeScript, intlayer test in CI |
| Lazy loading | Not needed, each build holds one locale | Whole locale file, split by hand | ✅ Per scope (route or component) | ✅ Per component and per locale |
| Signals | Not applicable, text is static | Pipe and Observables | translateSignal() | useIntlayer() returns a Signal |
| Build setup | ng add @angular/localize, locales in angular.json | None | None | @angular-builders/custom-esbuild and an esbuild plugin |
| Translator workflow | ✅ XLIFF, the format TMS tools expect | JSON | JSON | .content.ts/JSON, sync plugins, visual editor, CLI AI fill |
A few rows need context.
Message IDs in @angular/localize. Without a custom ID (i18n="@@cartTitle"), each message's ID is a hash of its source text. Fix a typo in the English copy and every translation of that message is orphaned until the translators redo it. Set custom IDs from day one.
Splitting with ngx-translate. The default loader downloads the full fr.json, so every page carries the strings of every other page. You can split by feature with a custom loader or several TranslateService instances, but nothing enforces it. The per-component vs centralized i18n post covers the trade-off.
Scopes in Transloco. A scope is a folder of JSON files (i18n/cart/en.json) loaded when a route or component provides it. It is the closest runtime libraries get to per-component content, and it works well as long as shared components do not reach into another feature's scope.
Intlayer's builder. Angular CLI does not expose esbuild plugins, so Intlayer needs @angular-builders/custom-esbuild in angular.json. It is a small change, but it is a third-party builder to keep in step with Angular upgrades. The Angular setup guide shows the full configuration.
Commit activity
@angular/localize lives in the angular/angular monorepo, so its commit count is not comparable and is left out.
- ngx-translate/core
- jsverse/transloco
- aymericzip/intlayer
デフォルトブランチのコミット数、出典: GitHub API。
npm downloads
- @angular/localize
- @ngx-translate/core
- @jsverse/transloco
- angular-intlayer
出典: npm レジストリのダウンロード API。
Downloads measure history more than current choices: ngx-translate is still installed by every app started before Transloco existed, and AI assistants keep suggesting it because it dominates the code they were trained on. Transloco moved from @ngneat/transloco to @jsverse/transloco in 2024, and the old scope is still downloaded.
The same component with each library
A cart summary with a title and a plural. The template barely changes, what changes is where the strings live and what the compiler knows about them.
コードをクリップボードにコピー
コードをクリップボードにコピー
コードをクリップボードにコピー
The English text stays in the template. Translators work on the extracted XLIFF, and each locale becomes its own build. Strings in TypeScript use the $localize tag.
コードをクリップボードにコピー
コードをクリップボードにコピー
コードをクリップボードにコピー
The ICU plural only works with ngx-translate-messageformat-compiler, the default parser only replaces {{count}}. "cart.titel" compiles and renders the raw key at runtime.
コードをクリップボードにコピー
コードをクリップボードにコピー
コードをクリップボードにコピー
The cart scope is fetched when the component is first rendered. ICU plurals need @jsverse/transloco-messageformat. Keys are untyped, transloco-keys-manager reports missing and unused ones.
コードをクリップボードにコピー
コードをクリップボードにコピー
All locales sit in one file beside the component. Types are generated at build, so content().titel fails ng build, and a locale missing from t() is flagged in the editor.
Which one fits your app
@angular/localize. Each locale is a separate build with its own URL, prerendered pages ship already translated, and there is no i18n runtime to load. The one-build-per-locale cost is low when the app is mostly content and language changes are rare. Pair it with correct hreflang tags, see the hreflang guide.
A runtime option. Reloading into another build loses in-memory state, and a language menu that reloads the app feels broken. ngx-translate is enough for a small app with two or three locales. Transloco is the safer runtime pick past a dozen features, thanks to scopes.
@angular/localize exports XLIFF, which every TMS reads, and the source text in the template gives translators real context. ngx-translate and Transloco JSON is also widely supported. Check that your vendor handles ICU plurals before choosing a runtime library, since both need a plugin for them.
Transloco scopes or Intlayer. Both avoid shipping every feature's strings to every route. The difference is enforcement: a Transloco scope is a convention, an Intlayer dictionary is bundled only where useIntlayer() imports it. See bundle optimization and dynamic dictionaries.
Only Intlayer types keys out of the box. With ngx-translate and Transloco, a typo in a key compiles and shows up in production as a raw key. Transloco Keys Manager can catch it in CI, which is better than nothing but not the same as a compile error. The detecting missing translations post compares the approaches.
Colocated content plus a CLI that fills missing locales is the shortest path. Intlayer's fill command runs with your own API key and only re-translates what changed. With XLIFF or JSON catalogs, you will script the same loop yourself.
Where each one falls short
@angular/localize: one build and one deployment per locale, reload on language change, hashed IDs that orphan translations when source text changes, and no way to load translations from a CMS after build without bootstrapping tricks.ngx-translate: untyped keys, plurals and ICU through a plugin, the full locale file on every page, an impure pipe that re-evaluates on every change detection, and noLOCALE_IDhandling for dates and numbers.- Transloco: untyped keys, ICU through a plugin, and scopes that are a convention rather than a guarantee. Several plugins to assemble for what
@angular/localizegives natively. Intlayer: a third-party builder in
angular.json, a smaller Angular community than the other three, partial ICU support, and content spread across the codebase by design, so exporting one file for a translator needs the sync JSON plugin or the CLI.
Migrating from ngx-translate
The @intlayer/ngx-translate compat adapter keeps TranslateService, the translate pipe and the [translate] directive working while Intlayer serves the content, so templates can be moved one at a time. The migration guide walks through it. For Transloco or @angular/localize, the sync JSON plugin can keep existing JSON catalogs as the source of truth during the move.
Frequently Asked Questions
Yes. After years of low activity, the project got a new maintainer in 2024 and has since shipped standalone APIs such as provideTranslateService. Its design has not changed: runtime JSON, string keys, plurals through a plugin.
Transloco, unless the app is small. It covers what ngx-translate does and adds scopes, signal helpers, SSR guidance and tooling for keys. The two APIs are close enough that switching later is mostly mechanical, but there is no reason to start with the simpler one if the app will grow.
Not as designed. Translations are inlined at build time, so another language means another build. You can call loadTranslations() before bootstrap to load translations at runtime, but switching still requires restarting the app.
The library matters less than the routing: one URL per locale, hreflang tags, <html lang> and translated server-rendered HTML. @angular/localize gets those almost for free since each locale is a separate build. Runtime libraries need SSR and localized routes to match it. See internationalization and SEO.
Yes, through Vite. See the Analog guide.
Going further
Same comparison for
コメント
まだコメントはありません。最初のコメントを共有しましょう。
