Ask your question and get a summary of the document by referencing this page and the AI provider of your choice
Version History
- "Init history"v9.8.523/11/2026
The content of this page was translated using an AI.
See the last version of the original content in EnglishIf you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy doc Markdown to clipboard
Migrating from ngx-translate to Intlayer
Why migrate from ngx-translate to Intlayer?
ngx-translate fetches locale files at runtime through TranslateHttpLoader, which delays the first render. Intlayer compiles dictionaries at build time, so translations are available immediately.
Keys are typed against your dictionaries: invalid keys fail at build time. Content can be co-located with the components that use it.
Co-located content reduces the context needed by LLMs. Intlayer ships a CLI to test for missing translations, an LSP, an MCP server and agent skills.
Translate missing messages in your CI/CD pipeline with the LLM of your choice, or in the background with the web platform.
Intlayer provides a self-hosted visual editor and a full CMS so translators and copywriters can edit content in real time.
To understand where these libraries come from, read the history of JavaScript i18n.
Migration strategies
- Compat adapter (recommended for existing apps): Install
@intlayer/ngx-translate. It exposes the same API as@ngx-translate/core(provideTranslateService,TranslateService,TranslatePipe,TranslateDirective,TranslateModule) and serves messages from Intlayer dictionaries. Your templates stay unchanged. - Full migration: Gradually replace ngx-translate calls with
useIntlayerfromangular-intlayerand.content.tsfiles co-located with your components.
Table of Contents
Quick migration
Install Dependencies
bashCopy codeCopy the code to the clipboard
The
--interactiveflag is optional. Useintlayer-cli initif you're an AI agent.The command detects your environment and installs the required packages, for example:
bashCopy codeCopy the code to the clipboard
Keep
@ngx-translate/coreinstalled: it provides the TypeScript types.@ngx-translate/http-loadercan be removed.Configure Intlayer
Point the
syncJSONplugin at your existing translation files. With one file per namespace (src/i18n/en/home.json), each file becomes a dictionary:intlayer.config.tsCopy codeCopy the code to the clipboard
import { Locales, type IntlayerConfig } from "intlayer"; import { syncJSON } from "@intlayer/sync-json-plugin"; const config: IntlayerConfig = { internationalization: { locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH], defaultLocale: Locales.ENGLISH, }, plugins: [ syncJSON({ // matches ngx-translate placeholder syntax: {{name}} format: "i18next", // ./src/i18n/en/home.json → dictionary `home` source: ({ key, locale }) => `./src/i18n/${locale}/${key}.json`, }), ], }; export default config;'home.title' | translateresolves to thetitlefield of thehomedictionary. If you use a single file per locale (src/assets/i18n/en.json) with nested keys, usesource: ({ locale }) => `./src/assets/i18n/${locale}.json`instead: each top-level key becomes a dictionary.Add the esbuild plugin
The Angular CLI accepts esbuild plugins through
@angular-builders/custom-esbuild. Create a plugins file:esbuild.plugins.tsCopy codeCopy the code to the clipboard
Then reference it in
angular.json:angular.jsonCopy codeCopy the code to the clipboard
The plugin runs the Intlayer build and resolves
@ngx-translate/coreto@intlayer/ngx-translate, so no source file changes are needed.Building with Vite (Analog)? Use
ngxTranslateVitePlugin()from@intlayer/ngx-translate/plugininstead.Remove the HTTP loader
Keep
provideTranslateService(), but drop theloaderoption: messages come from Intlayer dictionaries.src/app/app.config.tsCopy codeCopy the code to the clipboard
Translations no longer go through a loader, so
TranslateHttpLoaderand@ngx-translate/http-loadercan be removed.
Your templates and services keep working unchanged:
Copy the code to the clipboard
Copy the code to the clipboard
Complete migration
Explicit import renaming (optional)
OptionalThe esbuild plugin already handles aliasing. To make the dependency explicit:
Show all table contentOpen the table in a modal to view all data content clearly
Before After import { TranslateService } from '@ngx-translate/core'import { TranslateService } from '@intlayer/ngx-translate'import { TranslatePipe } from '@ngx-translate/core'import { TranslatePipe } from '@intlayer/ngx-translate'import { provideTranslateService } from '@ngx-translate/core'import { provideTranslateService } from '@intlayer/ngx-translate'Move content to .content.ts files
OptionalNew components can use native Intlayer content, side by side with existing ngx-translate calls. Register
provideIntlayer()fromangular-intlayernext toprovideTranslateService()inapp.config.ts, then:src/app/home.content.tsCopy codeCopy the code to the clipboard
src/app/home.component.tsCopy codeCopy the code to the clipboard
Enable AI-powered translation
OptionalbashCopy codeCopy the code to the clipboard
Filled translations are written back to your JSON files. See the CLI documentation for AI configuration.
What you can delete after migration
Open the table in a modal to view all data content clearly
| File / pattern | Why it's no longer needed |
|---|---|
TranslateHttpLoader / custom loaders | Dictionaries are compiled and loaded by Intlayer. |
@ngx-translate/http-loader | No runtime fetch of translation files. |
provideHttpClient() (if only used for translations) | Same reason. |
Configure TypeScript
Include the generated types in your tsconfig.json:
Copy the code to the clipboard
Git Configuration
Copy the code to the clipboard
