feat(lite): persit language change (#6443)

This commit is contained in:
Mathieu 2022-10-04 10:44:06 +02:00 committed by Julien Fontanet
parent 4621fb4e9b
commit b566e0fd46
2 changed files with 6 additions and 2 deletions

View File

@ -23,7 +23,8 @@
</template>
<script lang="ts" setup>
import { computed } from "vue";
import { computed, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import {
faEarthAmericas,
@ -35,6 +36,9 @@ import AccountButton from "@/components/AccountButton.vue";
import FormWidget from "@/components/FormWidget.vue";
const router = useRouter();
const { locale } = useI18n();
watch(locale, (newLocale) => localStorage.setItem("lang", newLocale));
const colorMode = useLocalStorage<string>("colorMode", "dark");
const toggleTheme = () => {

View File

@ -3,7 +3,7 @@ import en from "@/locales/en.json";
import fr from "@/locales/fr.json";
export default createI18n<[typeof en], "en" | "fr">({
locale: "en",
locale: localStorage.getItem("lang") ?? "en",
fallbackLocale: "en",
messages: {
en,