I have been using i18n to translate a Vue3 project with TypeScript, and I am stuck on getting the change locale button to work. Whenever I try, it returns an error regarding the question title. Does anyone have any insights on how to resolve this issue? Below is my code snippet:
<template>
<div>
<span @click="changeLocale('pt-br')" class="flag-icon flag-icon-br m-2"></span>
<span @click="changeLocale('en-uw')" class="flag-icon flag-icon-us m-2"></span>
<span @click="changeLocale('es-es')" class="flag-icon flag-icon-es m-2"></span>
</div>
</template>
<script setup lang = "ts">
export default {
methods: {
changeLocale(locale){
this.$root.$i18n.locale = locale;
}
}
}
</script>
<style scoped>
.m-2{
margin: 2px;
}
</style>