From 909d1cba1df76bcbd588e8347ca8c3d1925c7ed6 Mon Sep 17 00:00:00 2001
From: Alice <alice.poggioli@hotmail.fr>
Date: Wed, 13 Nov 2019 12:23:13 +0100
Subject: [PATCH] language selector works.

---
 src/includes/mentor/components/header.pug |  4 ++++
 src/scripts/coopstarter.js                | 19 ++++++++++++++-----
 translation/en.yml                        |  1 -
 translation/fr.yml                        |  2 +-
 4 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/includes/mentor/components/header.pug b/src/includes/mentor/components/header.pug
index b9f62c26..363919fb 100644
--- a/src/includes/mentor/components/header.pug
+++ b/src/includes/mentor/components/header.pug
@@ -16,6 +16,10 @@
                 label-languages=''
                 naked
             )
+<<<<<<< HEAD
+=======
+
+>>>>>>> language selector works.
             .dropdownWrapper
                 sib-display#mentor-account-picture.dropdownLabel(
                     bind-user
diff --git a/src/scripts/coopstarter.js b/src/scripts/coopstarter.js
index 675b9d71..bed5c99e 100644
--- a/src/scripts/coopstarter.js
+++ b/src/scripts/coopstarter.js
@@ -333,14 +333,23 @@ function manageSelectLanguage() {
   const languageSelects = document.getElementsByClassName("languageChoice")
   for (let item of languageSelects) {
     item.addEventListener("change", function() {
+      //We listen the selected option for the language
       uriLanguge = item.querySelector("option:checked").value
-      document.cookie = "langData=j%3A%7B%22langIndice%22%3A%22fr%22%7D"
+
+      //We retrieve element of the url
+      var pathAfterThePrefix = window.location.pathname.split('/')[2];
+      var base_url = location.host
+
+      //If the selected language is french
       if (uriLanguge === '{"@id": "http://localhost:8000/languages/1/"}') {
-        document.cookie = "langData=j%3A%7B%22langIndice%22%3A%22fr%22%7D"
-        location.reload()
+        //Redirection with the appropriate prefixe.
+        var redirect = "http://"+base_url+'/fr/'+pathAfterThePrefix
+
+        document.location.href = redirect
       } else {
-        document.cookie = "langData=j%3A%7B%22langIndice%22%3A%22en%22%7D"
-        location.reload()
+        var redirect = "http://"+base_url+'/en/'+pathAfterThePrefix
+        document.location.href = redirect
+        
       }
       
     })
diff --git a/translation/en.yml b/translation/en.yml
index 22341ac9..474b04d2 100644
--- a/translation/en.yml
+++ b/translation/en.yml
@@ -1,5 +1,4 @@
 ---
-title: My amazing website
 Dashboard : Dashboard
 ResourcesDatabase : Resources database
 MyAccount : My account
diff --git a/translation/fr.yml b/translation/fr.yml
index 7ac847be..2e78a588 100644
--- a/translation/fr.yml
+++ b/translation/fr.yml
@@ -1,5 +1,4 @@
 ---
-title: mon super sit
 Dashboard : Tableau de board
 ResourcesDatabase : Base de donnée de ressource
 MyAccount : Mon compte
@@ -68,6 +67,7 @@ SendRequest : Envoyer la demande
 MandatoryInformation : Informations obligatoires
 ComplementaryInformation : Informations complémentaires
 WithThisResourceBeAbleTo : Grâce à cette ressource, vous serez en mesure de
+WatchThePresentation : Regarder la présentation
 WhatValidationProcess : Qu'est-ce qu'un processus de validation ?
 MentorUploadResourceToDatabase: Le mentor télécharge une ressource dans la base de données
 ResourceSentToQualifiedPeersForValidation : La ressource est envoyée à des pairs qualifiés pour validation.
-- 
GitLab