From 414a59f4de696ee1202da57e6301308e70500df8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de>
Date: Fri, 8 Mar 2019 17:37:32 +0100
Subject: [PATCH] Add i18n to footer

---
 .../shared/footer/footer.component.html       |  4 +-
 .../shared/footer/footer.component.ts         | 43 ++++++++++++++-----
 .../statistics-page.component.ts              |  2 +-
 src/assets/i18n/home/de.json                  |  8 +++-
 src/assets/i18n/home/en.json                  |  8 +++-
 5 files changed, 49 insertions(+), 16 deletions(-)

diff --git a/src/app/components/shared/footer/footer.component.html b/src/app/components/shared/footer/footer.component.html
index 4a9a0908d..88fad08f0 100644
--- a/src/app/components/shared/footer/footer.component.html
+++ b/src/app/components/shared/footer/footer.component.html
@@ -7,12 +7,12 @@
     <span class="fill-remaining-space"></span>
     <button mat-button (click)="navToDSGVO()">
       <mat-icon>security</mat-icon>
-      DSGVO
+      {{ 'footer.dsgvo' | translate}}
     </button>
     <span class="fill-remaining-space"></span>
     <button mat-button (click)="navToImprint()">
       <mat-icon>info</mat-icon>
-      Impressum
+      {{ 'footer.imprint' | translate}}
     </button>
   </mat-toolbar>
 </footer>
diff --git a/src/app/components/shared/footer/footer.component.ts b/src/app/components/shared/footer/footer.component.ts
index b13f6cc82..6a744993f 100644
--- a/src/app/components/shared/footer/footer.component.ts
+++ b/src/app/components/shared/footer/footer.component.ts
@@ -1,7 +1,9 @@
+import { LanguageService } from './../../../services/util/language.service';
 import { Component, OnInit } from '@angular/core';
 import { NotificationService } from '../../../services/util/notification.service';
 import { Router } from '@angular/router';
 import { MatDialog } from '@angular/material';
+import { TranslateService } from '@ngx-translate/core';
 
 @Component({
   selector: 'app-footer',
@@ -13,18 +15,29 @@ export class FooterComponent implements OnInit {
   blogUrl = 'https://arsnova.thm.de/blog/';
   dsgvoUrl = 'https://arsnova.thm.de/blog/datenschutzerklaerung/';
   imprUrl = 'https://arsnova.thm.de/blog/impressum/';
-  constructor(
-    public notificationService: NotificationService,
-    public router: Router,
-    public dialog: MatDialog
-  ) { }
+
+  open: string;
+
+  constructor(public notificationService: NotificationService,
+              public router: Router,
+              public dialog: MatDialog,
+              private translateService: TranslateService,
+              private langService: LanguageService) {
+                langService.langEmitter.subscribe(lang => translateService.use(lang));
+              }
 
   ngOnInit() {
+    this.translateService.use(localStorage.getItem('currentLang'));
+    this.translateService.get('footer.open').subscribe(message => {
+      this.open = message;
+    });
   }
 
   navToBlog() {
-    this.notificationService.show('Der Blog wird in einem neuen Fenster geöffnet..', 'Öffnen' , {
-      duration: 4000
+    this.translateService.get('footer.will-open').subscribe(message => {
+      this.notificationService.show('Blog' + message, this.open, {
+        duration: 4000
+      });
     });
     this.notificationService.snackRef.afterDismissed().subscribe(info => {
       if (info.dismissedByAction === true) {
@@ -33,8 +46,12 @@ export class FooterComponent implements OnInit {
     });
   }
   navToDSGVO() {
-    this.notificationService.show('Die Datenschutzverordnung wird in einem neuen Fenster geöffnet..', 'Öffnen' , {
-      duration: 5000
+    this.translateService.get('footer.will-open').subscribe(message => {
+      this.translateService.get('footer.dsgvo').subscribe(what => {
+        this.notificationService.show(what + message, this.open, {
+          duration: 4000
+        });
+      });
     });
     this.notificationService.snackRef.afterDismissed().subscribe(info => {
       if (info.dismissedByAction === true) {
@@ -43,8 +60,12 @@ export class FooterComponent implements OnInit {
     });
   }
   navToImprint() {
-    this.notificationService.show('Das Impressum wird in einem neuen Fenster geöffnet..', 'Öffnen' , {
-      duration: 5000
+    this.translateService.get('footer.will-open').subscribe(message => {
+      this.translateService.get('footer.imprint').subscribe(what => {
+        this.notificationService.show(what + message, this.open, {
+          duration: 4000
+        });
+      });
     });
     this.notificationService.snackRef.afterDismissed().subscribe(info => {
       if (info.dismissedByAction === true) {
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 dd6cb63d7..9ae19ce39 100644
--- a/src/app/components/shared/statistics-page/statistics-page.component.ts
+++ b/src/app/components/shared/statistics-page/statistics-page.component.ts
@@ -40,10 +40,10 @@ export class StatisticsPageComponent implements OnInit {
     }
     this.getRoom(localStorage.getItem('roomId'));
     this.tabGroup.selectedIndex = 1;
+    this.translateService.use(localStorage.getItem('currentLang'));
   }
 
   getRoom(id: string): void {
-    this.translateService.use(localStorage.getItem('currentLang'));
     this.roomService.getRoom(id).subscribe(room => {
       this.contentGroups = room.contentGroups;
       if (this.contentGroups) {
diff --git a/src/assets/i18n/home/de.json b/src/assets/i18n/home/de.json
index 8f779d1bd..891968049 100644
--- a/src/assets/i18n/home/de.json
+++ b/src/assets/i18n/home/de.json
@@ -71,5 +71,11 @@
 		"description": "Beschreibung",
 		"max-ls": "Max. Zeichen:",
 		"create-session": "Session erstellen"
-	}
+  },
+  "footer": {
+    "dsgvo": "DSGVO",
+    "imprint": "Impressum",
+    "will-open": " wird in einem neuen Fenster geöffnet..",
+    "open": "Öffnen"
+  }
 }
diff --git a/src/assets/i18n/home/en.json b/src/assets/i18n/home/en.json
index 42504f2b9..3da52631f 100644
--- a/src/assets/i18n/home/en.json
+++ b/src/assets/i18n/home/en.json
@@ -71,5 +71,11 @@
 		"description": "Description",
 		"max-ls": "Max. letters / signs:",
 		"create-session": "Create session"
-	}
+	},
+  "footer": {
+    "dsgvo": "GDPR",
+    "imprint": "Imprint",
+    "will-open": " will be opened in a new tab..",
+    "open": "Open"
+  }
 }
-- 
GitLab