ngx-translate / core

The internationalization (i18n) library for Angular
MIT License
4.51k stars 575 forks source link

currentLang doesn't get defaultLanguage setting #1177

Open daboudii opened 4 years ago

daboudii commented 4 years ago

Current behavior

In app.module.ts, translateModule is imported with a default language en.

in app.component.ts, this.translate.currentLang = undefined. I need to use this.translate.use('en');I feel it is a bit redundant to get this.translate.currentLang = 'en'

Expected behavior

this.translate.currentLang = 'en'. as soon a defaultLanguage is set

Minimal reproduction of the problem with instructions

app.module.ts

imports: [
  TranslateModule.forRoot({
      defaultLanguage: 'en',
  }),
],

app.component.ts

ngOnInit() {
   this.currentLang = this.translate.currentLang;
    console.log(this.currentLang);
  }

Environment


ngx-translate version: 12.1.1
Angular version: 9.0.1

Browser:
- [x] Firefox version 73

For Tooling issues:
- Node version: v12.15.0
- Platform:  Linux
LoganDupont commented 4 years ago

@ocombe is it possible to have a look at this one? I would also expect that the currentLanguage would contain the defaultLanguage.