From 94bdc0d40b1cb3f2ccfee439a42df2ea004525b1 Mon Sep 17 00:00:00 2001 From: JuleSch Date: Wed, 5 Feb 2020 16:56:17 +0100 Subject: [PATCH] feat(service): allow empty default language string (#972) Fixes #971 --- projects/ngx-translate/core/src/lib/translate.service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/ngx-translate/core/src/lib/translate.service.ts b/projects/ngx-translate/core/src/lib/translate.service.ts index 3c08ef00..ca5b17ca 100644 --- a/projects/ngx-translate/core/src/lib/translate.service.ts +++ b/projects/ngx-translate/core/src/lib/translate.service.ts @@ -169,7 +169,7 @@ export class TranslateService { if (typeof pending !== "undefined") { // on init set the defaultLang immediately - if (!this.defaultLang) { + if (this.defaultLang == null) { this.defaultLang = lang; } @@ -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); } @@ -438,7 +438,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); } }