Loading...
Loading...
ALWAYS use when working with Angular i18n, internationalization, localization, translations, or multi-language support in Angular applications.
npx skill4agent add oguzhan18/angular-ecosystem-skills angular-i18n@Component({
template: `
<h1 i18n="@@welcome">Welcome to our app!</h1>
<p i18n="@@greeting">Hello, world!</p>
`
})
export class HomeComponent {}@Component({
template: `
<p i18n="@@userCount">
There are { count, plural, =0 { no users } =1 { one user } other { {{ count }} users } } in the system.
</p>
`
})
export class UsersComponent {
count = 5;
}@Component({
template: `
<p i18n="@@message">
{ gender, select, male {He} female {She} other {They} } is attending.
</p>
`
})
export class MessageComponent {}ng extract-i18n --output-path src/localeng build --localize{
"projects": {
"my-app": {
"i18n": {
"locales": {
"en": "src/locale/messages.en.xlf",
"es": "src/locale/messages.es.xlf",
"fr": "src/locale/messages.fr.xlf"
}
}
}
}
}@Component({
template: `
<img i18n-title title="Logo" src="logo.png" />
<a i18n-href href="/about" hreflang="es">About</a>
`
})
export class HeaderComponent {}import { $localize } from '@angular/localize';
$localize`:@@greeting:Hello, ${name}:name:World!`;// Alternative: use @ngx-translate/core
import { TranslateModule } from '@ngx-translate/core';
@NgModule({
imports: [TranslateModule.forRoot()]
})
export class AppModule {}// Using @ngx-translate
this.translate.getTranslation('en').subscribe(translations => {
// Load translations
});