From a5ea6280fc86a8edad728514b1a68b4a77b4d6b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Thu, 3 Oct 2019 15:01:37 -0400 Subject: [PATCH 1/5] fix(language) Get/set language is desynchronized --- packages/core/src/lib/language/shared/language.service.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/core/src/lib/language/shared/language.service.ts b/packages/core/src/lib/language/shared/language.service.ts index 18f3d7da5d..b6e04c6442 100644 --- a/packages/core/src/lib/language/shared/language.service.ts +++ b/packages/core/src/lib/language/shared/language.service.ts @@ -10,12 +10,14 @@ export class LanguageService { this.translate.setDefaultLang(lang); } + private language: string = this.translate.getBrowserLang(); + public getLanguage(): string { - const browserLang = this.translate.getBrowserLang(); - return browserLang.match(/en|fr/) ? browserLang : 'en'; + return this.language.match(/en|fr/) ? this.language : 'en'; } public setLanguage(language: string) { + this.language= language.match(/en|fr/) ? language : 'en'; this.translate.use(language); this.translate.reloadLang(language); } From 817a53f4d88be5246147becb3a27ad5e9363b416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Thu, 3 Oct 2019 15:08:07 -0400 Subject: [PATCH 2/5] typo --- packages/core/src/lib/language/shared/language.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/lib/language/shared/language.service.ts b/packages/core/src/lib/language/shared/language.service.ts index b6e04c6442..73fe809001 100644 --- a/packages/core/src/lib/language/shared/language.service.ts +++ b/packages/core/src/lib/language/shared/language.service.ts @@ -18,7 +18,7 @@ export class LanguageService { public setLanguage(language: string) { this.language= language.match(/en|fr/) ? language : 'en'; - this.translate.use(language); - this.translate.reloadLang(language); + this.translate.use(this.language); + this.translate.reloadLang(this.language); } } From ce9a173466b6f5ccfa308da77c27773d9a2dfde2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Thu, 3 Oct 2019 16:23:38 -0400 Subject: [PATCH 3/5] Update language.service.ts --- packages/core/src/lib/language/shared/language.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/lib/language/shared/language.service.ts b/packages/core/src/lib/language/shared/language.service.ts index 73fe809001..68527e6adc 100644 --- a/packages/core/src/lib/language/shared/language.service.ts +++ b/packages/core/src/lib/language/shared/language.service.ts @@ -17,7 +17,7 @@ export class LanguageService { } public setLanguage(language: string) { - this.language= language.match(/en|fr/) ? language : 'en'; + this.language = language.match(/en|fr/) ? language : 'en'; this.translate.use(this.language); this.translate.reloadLang(this.language); } From c632492db1ba6020a59f6dc40e001cb7511174f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Thu, 3 Oct 2019 16:25:39 -0400 Subject: [PATCH 4/5] Update language.service.ts --- packages/core/src/lib/language/shared/language.service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/src/lib/language/shared/language.service.ts b/packages/core/src/lib/language/shared/language.service.ts index 68527e6adc..d9bed2d3cd 100644 --- a/packages/core/src/lib/language/shared/language.service.ts +++ b/packages/core/src/lib/language/shared/language.service.ts @@ -5,13 +5,13 @@ import { TranslateService } from '@ngx-translate/core'; providedIn: 'root' }) export class LanguageService { + private language: string = this.translate.getBrowserLang(); + constructor(public translate: TranslateService) { const lang = this.getLanguage(); this.translate.setDefaultLang(lang); } - - private language: string = this.translate.getBrowserLang(); - + public getLanguage(): string { return this.language.match(/en|fr/) ? this.language : 'en'; } From becc5530e4c4210e3f24b1c798b471924146959a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Thu, 3 Oct 2019 16:25:52 -0400 Subject: [PATCH 5/5] Update language.service.ts --- packages/core/src/lib/language/shared/language.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/lib/language/shared/language.service.ts b/packages/core/src/lib/language/shared/language.service.ts index d9bed2d3cd..b88f9df2f0 100644 --- a/packages/core/src/lib/language/shared/language.service.ts +++ b/packages/core/src/lib/language/shared/language.service.ts @@ -11,7 +11,7 @@ export class LanguageService { const lang = this.getLanguage(); this.translate.setDefaultLang(lang); } - + public getLanguage(): string { return this.language.match(/en|fr/) ? this.language : 'en'; }