Skip to content

Commit

Permalink
issue ngx-translate#971 handling empty default language string
Browse files Browse the repository at this point in the history
An empty string is now also allowed as default language.
It checks if the default language is null. 
The check for 'undefined' is implied because of the use of == instead of ===.
  • Loading branch information
JuleSch authored Dec 13, 2018
1 parent 920b95d commit cc94a2d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions projects/ngx-translate/core/src/lib/translate.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export class TranslateService {

if (typeof pending !== "undefined") {
// on init set the defaultLang immediately
if (!this.defaultLang) {
if (this.defaultLang == null) {
this.defaultLang = lang;
}

Expand Down Expand Up @@ -340,7 +340,7 @@ export class TranslateService {
res = this.parser.interpolate(this.parser.getValue(translations, key), interpolateParams);
}

if (typeof res === "undefined" && this.defaultLang && this.defaultLang !== this.currentLang && this.useDefaultLang) {
if (typeof res === "undefined" && this.defaultLang != null && this.defaultLang !== this.currentLang && this.useDefaultLang) {
res = this.parser.interpolate(this.parser.getValue(this.translations[this.defaultLang], key), interpolateParams);
}

Expand Down Expand Up @@ -457,7 +457,7 @@ export class TranslateService {
this.onLangChange.emit({lang: lang, translations: this.translations[lang]});

// if there is no default lang, use the one that we just set
if (!this.defaultLang) {
if (this.defaultLang == null) {
this.changeDefaultLang(lang);
}
}
Expand Down

0 comments on commit cc94a2d

Please sign in to comment.