I am new to angularJs. I am not able to use the translate service inside the ngOnInit() method for the labels defined as arrays inside the ngOnInit().
import { TranslateService } from '@ngx-translate/core';
import {
getLanguage
} from 'src/app/utils/localstorage.utils';
export class ViewModificationApprovalComponent implements OnInit {
constructor(
private httpService: HttpService,
public translate: TranslateService
) {
translate.addLangs(['en', 'es']);
translate.setDefaultLang(getLanguage());
}
ngOnInit() {
// this.translate.addLangs(['en', 'es']);
// this.translate.setDefaultLang(getLanguage());
payload: {
profileName: 'channelProfile',
schema: [
{
name: 'basic',
label: 'Basic',
sections: [
{
name: 'personalInformation',
label: 'Personal Information',
I need the label 'Personal Information' to be translated into other languages. While I am trying to do it with by using label : this.translate.instant('lang.info'), it is simply displaying lang.info but not the translated language as out. Maybe it is not being able to access the this.translate service
You might not have set up the key -> translation dictionary properly which the TranslateService will use to convert given text to a certain language. You might consider using the translateService.setTranslation(languageKey, jsonKeyToTranslationObject);
function or use a loader. Details can be found here.