ngx-translate / core

The internationalization (i18n) library for Angular
MIT License
4.53k stars 578 forks source link

Translate do not work in constructor for translations added in json files #865

Open ihd2911 opened 6 years ago

ihd2911 commented 6 years ago

Current behavior

constructor(
    private translate: TranslateService,
    private titleService: Title,
  ) {
    console.log('in');
    translate.setTranslation('en', {
      //HELLO: 'helloa '
    });
    translate.get("HELLO").subscribe((newTitle: string) => {
      console.log(newTitle);
    });
}

If i uncomment "HELLO: 'helloa '" translation starts working. If i comment it and same translation in i18 folder in assets folder, it stops working. It do not work only in constructor, where as translations work properly at other places

Environment


ngx-translate core version:9.1.1 
ngx-translate http-loader version:3.0.1
Angular version: 5.0            
ihd2911 commented 6 years ago

Duplicate of #758