add LanguageSwitcher component
This commit is contained in:
parent
889102af2b
commit
5efef91d03
2 changed files with 23 additions and 1 deletions
20
src/components/LanguageSwitcher.vue
Normal file
20
src/components/LanguageSwitcher.vue
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { Button } from '@/components/ui/button'
|
||||
|
||||
const { locale } = useI18n()
|
||||
|
||||
const toggleLanguage = () => {
|
||||
locale.value = locale.value === 'en' ? 'es' : 'en'
|
||||
}
|
||||
|
||||
const getLanguageLabel = () => {
|
||||
return locale.value === 'en' ? '🇪🇸 ES' : '🇺🇸 EN'
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Button variant="ghost" size="sm" @click="toggleLanguage" class="gap-1">
|
||||
{{ getLanguageLabel() }}
|
||||
</Button>
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue