Switching languages
For language management, use useLanguage
composition function,
which is reactive, so you can use it easily with v-model
:
<template>
<select v-model="language" class="lang-selector">
<option value="en">🇬🇧 English</option>
<option value="de">🇩🇪 Deutsch</option>
</select>
</template>
<script>
import { defineComponent } from 'vue';
import { useLanguage } from '@tolgee/vue';
export default defineComponent({
setup() {
const language = useLanguage();
return { language };
},
});
</script>
Of course you can use it also to manually get or set language.