diff --git a/client/app/src/app-data.service.ts b/client/app/src/app-data.service.ts index 07fce50694..fbd12d6b82 100644 --- a/client/app/src/app-data.service.ts +++ b/client/app/src/app-data.service.ts @@ -9,6 +9,7 @@ import {BehaviorSubject, Observable} from "rxjs"; export class AppDataService { private showLoadingPanelSubject: BehaviorSubject = new BehaviorSubject(false); showLoadingPanel$: Observable = this.showLoadingPanelSubject.asObservable(); + language:string = "en" updateShowLoadingPanel(newValue: boolean) { this.showLoadingPanelSubject.next(newValue); diff --git a/client/app/src/services/helper/mocks.ts b/client/app/src/services/helper/mocks.ts index 3cb58b55b6..acc6c82a87 100644 --- a/client/app/src/services/helper/mocks.ts +++ b/client/app/src/services/helper/mocks.ts @@ -14,13 +14,14 @@ interface Mocks { } class MockEngine { + language: string private mocks: Mocks = {}; private applyMock(mock: Mock): void { const e = document.querySelector(mock.selector) as HTMLElement | null; if (e) { - if (!mock.value || mock.language !== GL.language) { - mock.language = GL.language; + if (!mock.value || mock.language !== this.language) { + mock.language = this.language; if (typeof mock.mock === "function") { mock.value = mock.mock(e); } else { @@ -93,11 +94,4 @@ class MockEngine { } } -const GL = { - language: 'en', - get mockEngine() { - return mockEngine; - } -}; - export const mockEngine = new MockEngine(); \ No newline at end of file diff --git a/client/app/src/services/helper/translation.service.ts b/client/app/src/services/helper/translation.service.ts index 351a51c3f5..566de73c23 100644 --- a/client/app/src/services/helper/translation.service.ts +++ b/client/app/src/services/helper/translation.service.ts @@ -2,7 +2,8 @@ import {BehaviorSubject} from 'rxjs'; import {Injectable, inject} from "@angular/core"; import {TranslateService} from "@ngx-translate/core"; import {UtilsService} from "@app/shared/services/utils.service"; -import {DOCUMENT} from "@angular/common"; +import {AppDataService} from "@app/app-data.service"; +import {mockEngine} from "@app/services/helper/mocks"; @Injectable({ providedIn: "root", @@ -10,7 +11,7 @@ import {DOCUMENT} from "@angular/common"; export class TranslationService { private utilsService = inject(UtilsService); protected translate = inject(TranslateService); - private document = inject(DOCUMENT); + private appDataService = inject(AppDataService); language = ""; @@ -31,6 +32,8 @@ export class TranslationService { this.language = changedLanguage; this.changeLocale(this.language); this.translate.use(this.language).subscribe(() => { + this.appDataService.language = this.language + mockEngine.language = this.language if (callback) { callback(); }