I have recently started working on Angular 9 project, I am using ngx-translate for internationalization. I implemented basic poc using this https://stackblitz.com/github/ngx-translate/example
The issue is code inside constructor need to repeated multiple time in different components, I need to avoid that duplication of code in multiple components.
constructor(public translate: TranslateService) {
translate.addLangs(['en', 'fr']);
translate.setDefaultLang('en');
const browserLang = translate.getBrowserLang();
translate.use(browserLang.match(/en|fr/) ? browserLang : 'en');}
I tried following this approach Angular 5 - Service provider injection in all components with extends, but could not succeed.
Any help will be appreciated. Thanks