Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(service): allow empty default language string #972

Merged
merged 1 commit into from
Feb 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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