From 5205f77c2dc606576d14b317336d463b040db5b8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de>
Date: Thu, 28 Feb 2019 18:09:43 +0100
Subject: [PATCH] Add some i18n to statistic-component

---
 .../shared/statistic/statistic.component.ts        | 14 +++++++++++---
 .../statistics-page/statistics-page.component.ts   |  2 +-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/app/components/shared/statistic/statistic.component.ts b/src/app/components/shared/statistic/statistic.component.ts
index 19a5852f2..2d7540624 100644
--- a/src/app/components/shared/statistic/statistic.component.ts
+++ b/src/app/components/shared/statistic/statistic.component.ts
@@ -3,6 +3,8 @@ import { Chart } from 'chart.js';
 import { ActivatedRoute } from '@angular/router';
 import { ContentService } from '../../../services/http/content.service';
 import { ContentChoice } from '../../../models/content-choice';
+import { TranslateService } from '@ngx-translate/core';
+import { LanguageService } from '../../../services/util/language.service';
 
 export class AnswerList {
   label: string;
@@ -35,9 +37,14 @@ export class StatisticComponent implements OnInit {
   isLoading = true;
 
   constructor(protected route: ActivatedRoute,
-              private contentService: ContentService) { }
+              private contentService: ContentService,
+              private translateService: TranslateService,
+              protected langService: LanguageService) {
+              langService.langEmitter.subscribe(lang => translateService.use(lang));
+  }
 
   ngOnInit() {
+    this.translateService.use(localStorage.getItem('currentLang'));
     this.maxLength = innerWidth / 12;
     this.answers = new Array<string>();
     this.labels = new Array<string>();
@@ -65,11 +72,12 @@ export class StatisticComponent implements OnInit {
         this.answerList[i].answer = content.options[i].label;
       }
     }
-    this.labels.push('Abstentions');
+    this.translateService.get('statistic.abstentions').subscribe(label => {
+      this.labels.push(label);
+    });
     this.contentService.getAnswer(content.id).subscribe(answer => {
       this.data = answer.roundStatistics[0].independentCounts;
       this.data.push(answer.roundStatistics[0].abstentionCount);
-      console.log(this.data);
       this.chart = new Chart('chart', {
         type: 'bar',
         data: {
diff --git a/src/app/components/shared/statistics-page/statistics-page.component.ts b/src/app/components/shared/statistics-page/statistics-page.component.ts
index b1ca52aa6..2da2391fe 100644
--- a/src/app/components/shared/statistics-page/statistics-page.component.ts
+++ b/src/app/components/shared/statistics-page/statistics-page.component.ts
@@ -27,7 +27,7 @@ export class StatisticsPageComponent implements OnInit {
               private roomService: RoomService,
               private translateService: TranslateService,
               protected langService: LanguageService,
-              public dialog: MatDialog,) {
+              public dialog: MatDialog) {
               langService.langEmitter.subscribe(lang => translateService.use(lang));
   }
 
-- 
GitLab