From b254f6dff2a1166ee333e663c3a5248fff757ea5 Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Tue, 7 Jul 2020 15:39:01 +0300 Subject: [PATCH] fix: localization problem in dynamic layout when language changed --- .../lib/components/dynamic-layout.component.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/components/dynamic-layout.component.ts b/npm/ng-packs/packages/core/src/lib/components/dynamic-layout.component.ts index 49a0868967..bd09876ba6 100644 --- a/npm/ng-packs/packages/core/src/lib/components/dynamic-layout.component.ts +++ b/npm/ng-packs/packages/core/src/lib/components/dynamic-layout.component.ts @@ -1,9 +1,10 @@ -import { Component, Injector, OnDestroy, Type, Optional, SkipSelf } from '@angular/core'; +import { Component, Injector, OnDestroy, Optional, SkipSelf, Type } from '@angular/core'; import { ActivatedRoute, NavigationEnd, Router } from '@angular/router'; import { Store } from '@ngxs/store'; import { eLayoutType } from '../enums/common'; import { ABP } from '../models'; import { ReplaceableComponents } from '../models/replaceable-components'; +import { LocalizationService } from '../services/localization.service'; import { RoutesService } from '../services/routes.service'; import { ReplaceableComponentsState } from '../states/replaceable-components.state'; import { findRoute, getRoutePath } from '../utils/route-utils'; @@ -16,15 +17,18 @@ import { TreeNode } from '../utils/tree-utils'; `, }) export class DynamicLayoutComponent implements OnDestroy { layout: Type; + isLayoutShow = true; + constructor( injector: Injector, + private localizationService: LocalizationService, private store: Store, @Optional() @SkipSelf() dynamicLayoutComponent: DynamicLayoutComponent, ) { @@ -61,6 +65,15 @@ export class DynamicLayoutComponent implements OnDestroy { this.layout = layouts[expectedLayout].component; } }); + + this.listenToLanguageChange(); + } + + private listenToLanguageChange() { + this.localizationService.languageChange.pipe(takeUntilDestroy(this)).subscribe(() => { + this.isLayoutShow = false; + setTimeout(() => (this.isLayoutShow = true), 0); + }); } private getComponent(key: string): ReplaceableComponents.ReplaceableComponent {