-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #595 from Gid733/stable
Fix issue with table headers translates
- Loading branch information
Showing
2 changed files
with
41 additions
and
24 deletions.
There are no files selected for viewing
45 changes: 28 additions & 17 deletions
45
...ent/src/app/plugins/modules/time-planning-pn/layouts/time-planning-pn-layout.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,40 @@ | ||
import { AfterContentInit, Component, OnInit } from '@angular/core'; | ||
import { TranslateService } from '@ngx-translate/core'; | ||
import { translates } from './../i18n/translates'; | ||
import { AuthStateService } from 'src/app/common/store'; | ||
import {AfterContentInit, Component, OnInit} from '@angular/core'; | ||
import {TranslateService} from '@ngx-translate/core'; | ||
import {translates} from './../i18n/translates'; | ||
import {Store} from '@ngrx/store'; | ||
import {selectCurrentUserLocale} from 'src/app/state/auth/auth.selector'; | ||
import {addPluginToVisited, selectPluginsVisitedPlugins} from 'src/app/state'; | ||
import {take} from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'app-time-planning-pn-layout', | ||
template: `<router-outlet></router-outlet>`, | ||
template: ` | ||
<router-outlet></router-outlet>`, | ||
}) | ||
export class TimePlanningPnLayoutComponent | ||
implements AfterContentInit, OnInit { | ||
private selectCurrentUserLocale$ = this.store.select(selectCurrentUserLocale); | ||
export class TimePlanningPnLayoutComponent implements AfterContentInit, OnInit { | ||
private pluginName = 'time-planning'; | ||
|
||
constructor( | ||
private store: Store, | ||
private translateService: TranslateService, | ||
private authStateService: AuthStateService | ||
) {} | ||
store: Store | ||
) { | ||
store.select(selectPluginsVisitedPlugins) | ||
.pipe(take(1)) | ||
.subscribe(x => { | ||
// check current plugin in activated plugin | ||
if (x.findIndex(y => y === this.pluginName) === -1) { | ||
// add all plugin translates one time | ||
Object.keys(translates).forEach(locale => { | ||
this.translateService.setTranslation(locale, translates[locale], true); | ||
}); | ||
// add plugin to visited plugins | ||
store.dispatch(addPluginToVisited(this.pluginName)); | ||
} | ||
}); | ||
} | ||
|
||
ngOnInit() {} | ||
ngOnInit() { | ||
} | ||
|
||
ngAfterContentInit() { | ||
this.selectCurrentUserLocale$.subscribe((locale) => { | ||
const i18n = translates[locale]; | ||
this.translateService.setTranslation(locale, i18n, true); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters