From 488d2f7e1c63abaa817e7cf9dd45675225ab6022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de> Date: Tue, 6 Nov 2018 13:15:06 +0100 Subject: [PATCH] Make translation-service available for all participant-pages/components --- .../content-text-participant.component.ts | 11 ++++++++--- .../participant-content-carousel-page.component.ts | 3 --- .../room-participant-page.component.ts | 7 ++++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/app/components/participant/content-text-participant/content-text-participant.component.ts b/src/app/components/participant/content-text-participant/content-text-participant.component.ts index 234978ba7..d0f6e4706 100644 --- a/src/app/components/participant/content-text-participant/content-text-participant.component.ts +++ b/src/app/components/participant/content-text-participant/content-text-participant.component.ts @@ -3,6 +3,8 @@ import { ContentText } from '../../../models/content-text'; import { ContentAnswerService } from '../../../services/http/content-answer.service'; import { AnswerText } from '../../../models/answer-text'; import { NotificationService } from '../../../services/util/notification.service'; +import { TranslateService } from '@ngx-translate/core'; +import { LanguageService } from '../../shared/LanguageService'; @Component({ selector: 'app-content-text-participant', @@ -16,13 +18,16 @@ export class ContentTextParticipantComponent implements OnInit { isAnswerSent = false; constructor(private answerService: ContentAnswerService, - private notificationService: NotificationService) { - } + private notificationService: NotificationService, + private translateService: TranslateService, + protected langService: LanguageService) { + langService.langEmitter.subscribe(lang => translateService.use(lang)); +} ngOnInit() { + this.translateService.use(sessionStorage.getItem('currentLang')); } -// submitAnswer(answer: string) { submitAnswer() { if (this.textAnswer.trim().valueOf() === '') { this.notificationService.show('No empty answer allowed.'); diff --git a/src/app/components/participant/participant-content-carousel-page/participant-content-carousel-page.component.ts b/src/app/components/participant/participant-content-carousel-page/participant-content-carousel-page.component.ts index c9cbe0868..6791be5a4 100644 --- a/src/app/components/participant/participant-content-carousel-page/participant-content-carousel-page.component.ts +++ b/src/app/components/participant/participant-content-carousel-page/participant-content-carousel-page.component.ts @@ -1,8 +1,5 @@ import { Component, OnInit } from '@angular/core'; import { ContentType } from '../../../models/content-type.enum'; -import { AnswerOption } from '../../../models/answer-option'; -import { ContentChoice } from '../../../models/content-choice'; -import { ContentText } from '../../../models/content-text'; import { ContentService } from '../../../services/http/content.service'; import { ActivatedRoute } from '@angular/router'; import { Content } from '../../../models/content'; diff --git a/src/app/components/participant/room-participant-page/room-participant-page.component.ts b/src/app/components/participant/room-participant-page/room-participant-page.component.ts index 8942ede24..03f9b324d 100644 --- a/src/app/components/participant/room-participant-page/room-participant-page.component.ts +++ b/src/app/components/participant/room-participant-page/room-participant-page.component.ts @@ -3,6 +3,8 @@ import { Room } from '../../../models/room'; import { Location } from '@angular/common'; import { RoomService } from '../../../services/http/room.service'; import { ActivatedRoute, Router } from '@angular/router'; +import { TranslateService } from '@ngx-translate/core'; +import { LanguageService } from '../../shared/LanguageService'; @Component({ selector: 'app-room-participant-page', @@ -17,13 +19,16 @@ export class RoomParticipantPageComponent implements OnInit { constructor(private location: Location, private roomService: RoomService, private route: ActivatedRoute, - private router: Router) { + private translateService: TranslateService, + protected langService: LanguageService) { + langService.langEmitter.subscribe(lang => translateService.use(lang)); } ngOnInit() { this.route.params.subscribe(params => { this.getRoom(params['roomId']); }); + this.translateService.use(sessionStorage.getItem('currentLang')); } getRoom(id: string): void { -- GitLab