Soluție Angular i18n
Suport pentru componente standalone, signals și SSR pentru aplicații Angular.
Runtime translations in Angular, in three steps
Angular's built-in i18n compiles one bundle per locale. For translations that change without a rebuild, ngx-translate reads them from Better I18N at runtime.
Install the loader dependencies
ngx-translate provides the pipe, the service and the loader contract; core fetches and caches the messages.
npm install @ngx-translate/core @better-i18n/core
# @better-i18n/core ships zero dependencies —
# it is the same client our React SDKs are built on.Write a TranslateLoader backed by the CDN
TranslateLoader asks for an Observable per language, so rxjs from() around getMessages is the whole adapter.
import { Injectable } from '@angular/core'
import { TranslateLoader } from '@ngx-translate/core'
import { createI18nCore } from '@better-i18n/core'
import { from, Observable } from 'rxjs'
// Module scope: the 60s in-memory cache lives on the instance, so one
// client per app — not one per component.
const betterI18n = createI18nCore({
projectId: 'your-org/your-project', // Settings → General → Project ID
defaultLocale: 'en',
})
@Injectable({ providedIn: 'root' })
export class BetterI18nLoader implements TranslateLoader {
// TranslateLoader's contract: one Observable of messages per language.
getTranslation(lang: string): Observable<Record<string, unknown>> {
return from(betterI18n.getMessages(lang))
}
}
export { betterI18n }Provide it and switch at runtime
One provider in bootstrapApplication, then use() changes language with no page reload and no per-locale build.
import { bootstrapApplication } from '@angular/platform-browser'
import { importProvidersFrom } from '@angular/core'
import { TranslateModule, TranslateLoader } from '@ngx-translate/core'
import { AppComponent } from './app/app.component'
import { BetterI18nLoader } from './app/better-i18n.loader'
bootstrapApplication(AppComponent, {
providers: [
importProvidersFrom(
TranslateModule.forRoot({
defaultLanguage: 'en',
loader: { provide: TranslateLoader, useClass: BetterI18nLoader },
})
),
],
})How it works
Where an Angular string comes from
No per-locale bundle: the loader resolves a language at runtime and the edge answers it.
Read path — every locale load
The translate pipe reads what TranslateService already loaded.
0 network calls per render
getMessages(lang) inside the TranslateLoader — cached per language.
60s TTL · 0 deps
Cloudflare worker answers from the nearest edge cache.
max-age=60 · always 200
The published translation files the sync worker wrote.
source of truth
Fallback chain — tried in order when a hop fails
Write path — dashboard to app
Proposal reviewed in the dashboard, glossary enforced.
MCP · dashboard · CLI
Sync worker writes the locale files to R2.
better-i18n publish
Fire-and-forget purge of the affected keys and the manifest.
non-critical by design
The next getMessages() past the TTL returns the new copy.
~60s worst case
Pornire rapidă
Adaugă i18n în aplicația ta Angular cu pipe-uri și servicii.
import { Component, inject } from '@angular/core'
import { TranslateModule, TranslateService } from '@ngx-translate/core'
import { betterI18n } from './better-i18n.loader'
@Component({
selector: 'app-locale-switcher',
standalone: true,
imports: [TranslateModule],
template: `
<select (change)="switchTo($any($event.target).value)">
<option *ngFor="let l of languages" [value]="l.code">{{ l.name }}</option>
</select>
`,
})
export class LocaleSwitcherComponent {
private translate = inject(TranslateService)
languages: { code: string; name: string }[] = []
async ngOnInit() {
// Locales come from the project manifest, not a hardcoded array.
this.languages = await betterI18n.getLanguages()
}
switchTo(lang: string) {
// use() calls the loader, which hits the cache or the CDN.
this.translate.use(lang)
}
}In a template
The translate pipe and the service both read from the loader, so nothing in your components knows about the CDN.
<!-- app.component.html -->
<h1>{{ 'home.title' | translate }}</h1>
<p>{{ 'home.greeting' | translate: { name: 'World' } }}</p>
<!-- ICU plurals authored in the Better i18n dashboard -->
<p>{{ 'cart.items' | translate: { count: 3 } }}</p>
<app-locale-switcher />Funcționalități
Funcționează cu bibliotecile i18n populare pentru Angular
Better I18N completează biblioteca i18n Angular — gestionați traducerile vizual, colaborați cu traducătorii și implementați prin CDN.
Better I18N + @ngx-translate/core
Cea mai utilizată bibliotecă de traducere Angular. Traduceri runtime cu pipes, directive și injecție de servicii.Better I18N exportă în formatul JSON ngx-translate. Editați traducerile în dashboard, sincronizați automat cu repo-ul.
Better I18N + Angular i18n (built-in)
Sistemul oficial i18n al Angular cu compilare AOT, expresii ICU și extracție a traducerilor la build.Export în formatul Angular XLIFF. Better I18N gestionează fluxul de traducere, Angular CLI construiește pachete specifice locale.
Better I18N + Transloco
Bibliotecă i18n modernă și ușoară pentru Angular cu încărcare leneșă, pluginuri bogate și suport TypeScript excelent.Sincronizați traducerile în formatul JSON Transloco prin integrarea GitHub a Better I18N. Actualizări în timp real cu livrare CDN.
Similar
Explorați alte ghiduri pentru framework-uri
Get started
Începe să construiești cu Angular i18n
Plan gratuit disponibil. Nu este necesar card de credit.