@ngx-translate/core
Internationalization (i18n) library for Angular — translate your app using JSON files with runtime language switching and pipe/directive support.
@ngx-translate/core
AngularInternationalization (i18n) library for Angular — translate your app using JSON files with runtime language switching and pipe/directive support.
Fit
Bundle (gzip)
6.2 kB
23.8 kB raw
Install size includes transitive dependencies. Bundle size is gzipped browser payload.
Freshness
The Problem
Angular's built-in i18n requires rebuilding the app for each locale and doesn't support runtime language switching. Managing translations in separate HTML files is cumbersome for large apps.
What It Does
@ngx-translate/core loads translation JSON files at runtime and provides a TranslatePipe, TranslateDirective, and TranslateService for switching languages without a page reload. The @ngx-translate/http-loader fetches translation files lazily from your server.
Installation
npm install @ngx-translate/core @ngx-translate/http-loaderUsage Example
// app.module.ts
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { HttpClient } from '@angular/common/http';
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
@NgModule({
imports: [
TranslateModule.forRoot({
loader: { provide: TranslateLoader, useFactory: createTranslateLoader, deps: [HttpClient] },
defaultLanguage: 'en',
}),
],
})
export class AppModule {}<!-- template -->
<h1>{{ 'WELCOME.TITLE' | translate }}</h1>
<button (click)="translate.use('de')">Deutsch</button>Related packages
Angular Component Dev Kit — a set of behavior primitives for building accessible, high-quality UI components without prescribing any visual style.
@angular/materialAngularOfficial Material Design component library for Angular — 30+ accessible, themeable UI components built for Angular's ecosystem.
@ng-bootstrap/ng-bootstrapAngularAngular widgets built from scratch using Bootstrap CSS — no jQuery, no Popper.js, just pure Angular components.
ng-zorro-antdAngularEnterprise-grade UI component library for Angular based on Ant Design — 60+ production-ready components with a polished design system.
@ngneat/until-destroyAngularAutomatic RxJS subscription cleanup for Angular components — no more manual unsubscribe logic in ngOnDestroy.