From ccf3851d31a10441d9b0d3090acb2fea9cbb0e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de> Date: Mon, 5 Nov 2018 15:51:59 +0100 Subject: [PATCH] Fix translation for lazy-loaded modules in participant role --- .../home-participant-page.component.ts | 8 +++++++- .../components/participant/participant.module.ts | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/app/components/participant/home-participant-page/home-participant-page.component.ts b/src/app/components/participant/home-participant-page/home-participant-page.component.ts index cdf91279c..d2f584299 100644 --- a/src/app/components/participant/home-participant-page/home-participant-page.component.ts +++ b/src/app/components/participant/home-participant-page/home-participant-page.component.ts @@ -1,4 +1,6 @@ import { Component, OnInit } from '@angular/core'; +import { TranslateService } from '@ngx-translate/core'; +import { LanguageService } from '../../shared/LanguageService'; @Component({ selector: 'app-home-participant-page', @@ -7,9 +9,13 @@ import { Component, OnInit } from '@angular/core'; }) export class HomeParticipantPageComponent implements OnInit { - constructor() { } + constructor(private translateService: TranslateService, + protected langService: LanguageService) { + langService.langEmitter.subscribe(lang => translateService.use(lang)); + } ngOnInit() { + this.translateService.use(sessionStorage.getItem('currentLang')); } } diff --git a/src/app/components/participant/participant.module.ts b/src/app/components/participant/participant.module.ts index 17667eab2..b156b6380 100644 --- a/src/app/components/participant/participant.module.ts +++ b/src/app/components/participant/participant.module.ts @@ -1,20 +1,30 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { ParticipantRoutingModule } from './participant-routing.module'; -import { EssentialsModule } from '../essentials/essentials.module'; +import { EssentialsModule, HttpLoaderFactory} from '../essentials/essentials.module'; import { ContentChoiceParticipantComponent } from './content-choice-participant/content-choice-participant.component'; import { ContentTextParticipantComponent } from './content-text-participant/content-text-participant.component'; import { HomeParticipantPageComponent } from './home-participant-page/home-participant-page.component'; import { RoomParticipantPageComponent } from './room-participant-page/room-participant-page.component'; import { SharedModule } from '../shared/shared.module'; import { ParticipantContentCarouselPageComponent } from './participant-content-carousel-page/participant-content-carousel-page.component'; +import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; +import { HttpClient } from '@angular/common/http'; @NgModule({ imports: [ CommonModule, ParticipantRoutingModule, EssentialsModule, - SharedModule + SharedModule, + TranslateModule.forChild({ + loader: { + provide: TranslateLoader, + useFactory: (HttpLoaderFactory), + deps: [HttpClient] + }, + isolate: true + }) ], declarations: [ ContentChoiceParticipantComponent, -- GitLab