get language of quiz by query param

This commit is contained in:
Jen Looper
2021-01-01 11:16:47 -05:00
parent d8456b1318
commit 38bf490e86
2 changed files with 11 additions and 6 deletions

View File

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

View File

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