Вы можете использовать ngx-translate-core для перевода (прочитайте документ , чтобы установить его).
В вашем компоненте вы можете попробовать что-то вроде этого:
import { LangChangeEvent, TranslateService } from '@ngx-translate/core';
import { Component } from '@angular/core';
@Component({
selector: 'app-contact',
templateUrl: './contact.component.html'
})
export class YourComponent {
settings: any;
constructor(private translateService: TranslateService) {
// we will set the default lang to 'fr' but this part is generally done
// in your app.component.
this.translateService.setDefaultLang('fr');
this.translateService.use('fr');
// we launch manually a table settings here with the default lang setted
this.initTableSettings();
// listening on the lang changements
this.translateService.onLangChange.subscribe((event: LangChangeEvent) => {
this.translateService.use(event.lang);
// every time the languages will change, we reload the settings
this.initTableSettings();
});
}
initTableSettings(): void {
this.settings = {
actions: {
add: false,
edit: false,
delete: false
},
columns: {
date: {
title: this.translateService.instant('column_date')
},
sent: {
title: this.translateService.instant('column_sent')
},
billed: {
title: this.translateService.instant('column_billed')
}
}
};
}
}
И в вашем файле i18n (здесь fr.json):
{
"column_date": "<< your traduction in french here >>",
"column_sent": "<< your traduction in french here >>",
"column_billed": "<< your traduction in french here >>"
}
В документе вы можете увидеть, как установить и настроить TranslateService of Angular, в основном, как импортировать службу в модуль приложения, куда поместить файлы i18n и т. Д.