From 107425427bf3c447194b12dc051d51f93c0d3964 Mon Sep 17 00:00:00 2001 From: Simon C Date: Tue, 17 Jan 2023 16:46:50 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20Ajout=20de=20la=20traduction=20par=20d?= =?UTF-8?q?=C3=A9faut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Score.vue | 6 +- src/components/ScoresList.vue | 120 ++++++++++++++++++++-------------- src/stores.js | 5 ++ 3 files changed, 77 insertions(+), 54 deletions(-) diff --git a/src/components/Score.vue b/src/components/Score.vue index 700e756..270c662 100644 --- a/src/components/Score.vue +++ b/src/components/Score.vue @@ -32,12 +32,11 @@ function formatAnswers(answers) { ); return { id: answer.id, - title: translation.length > 0 ? translation[0].title : "", + title: translation.length > 0 ? translation[0].title : answer.title, weight: answer.weight, image: answer.image, }; }) - .filter((answer) => answer.title); } function formatScore(score) { @@ -51,12 +50,11 @@ function formatScore(score) { return { id: question.id, weight: answers[0].weight, - title: translation.length > 0 ? translation[0].title : "", + title: translation.length > 0 ? translation[0].title : question.title, answers: answers, splide: ref(), }; }) - .filter((question) => question.title); } const title = score ? score.title : ""; diff --git a/src/components/ScoresList.vue b/src/components/ScoresList.vue index 4a35ab6..e59c03a 100644 --- a/src/components/ScoresList.vue +++ b/src/components/ScoresList.vue @@ -3,33 +3,39 @@ import data from "@/data.json"; import { useStore } from "@/stores"; const store = useStore(); -const language = store.language; const translationKey = "languages_id"; const scores = data.filter((score) => { return ( !!score.translations.find( - (translation) => translation[translationKey] == language + (translation) => translation[translationKey] == store.language ) && score.results.length && score.questions.length ); }); function getTranslation(translations, key) { - return translations.find((translation) => translation[key] == language); + return translations.find((translation) => translation[key] == store.language); +} +function changeLanguage() { + store.changeLanguage() }