get language of quiz by query param

pull/152/head
Jen Looper 4 years ago
parent d8456b1318
commit 38bf490e86

@ -5,7 +5,6 @@
<label for="locale">locale</label> <label for="locale">locale</label>
<select v-model="locale"> <select v-model="locale">
<option>en</option> <option>en</option>
<option>fr</option>
<option>id</option> <option>id</option>
</select> </select>
</nav> </nav>
@ -29,13 +28,18 @@ export default {
Quiz, Quiz,
}, },
data() { data() {
return { locale: "en" }; return {
locale: "en",
};
}, },
watch: { watch: {
locale(val) { locale(val) {
this.$root.$i18n.locale = val; this.$root.$i18n.locale = val;
}, },
}, },
created() {
this.locale = this.$route.query.loc;
},
}; };
</script> </script>

@ -1,7 +1,6 @@
<template> <template>
<div class="card"> <div class="card">
<div v-for="q in questions" :key="q.id"> <div v-for="q in questions" :key="q.id">
<div v-if="route == q.id"> <div v-if="route == q.id">
<h2>{{ q.title }}</h2> <h2>{{ q.title }}</h2>
<hr /> <hr />
@ -38,12 +37,13 @@ export default {
complete: false, complete: false,
error: false, error: false,
route: "", route: "",
locale: "",
}; };
}, },
computed: { computed: {
questions() { questions() {
return this.$t("quizzes"); return this.$t("quizzes");
} },
}, },
i18n: { messages }, i18n: { messages },
@ -65,6 +65,7 @@ export default {
}, },
created() { created() {
this.route = this.$route.params.id; this.route = this.$route.params.id;
this.locale = this.$route.query.loc;
}, },
}; };
</script> </script>

Loading…
Cancel
Save