elk/components/nav/SelectLanguage.vue

25 lines
571 B
Vue
Raw Normal View History

<script lang="ts" setup>
2022-11-28 19:49:30 +03:00
import type { ComputedRef } from 'vue'
import type { LocaleObject } from '#i18n'
const { locale, t, setLocale } = useI18n()
const { locales } = useI18n() as { locales: ComputedRef<LocaleObject[]> }
</script>
<template>
<CommonDropdown>
<slot />
<template #popper>
<CommonDropdownItem
v-for="item in locales"
:key="item.code"
:checked="item.code === locale"
@click="setLocale(item.code)"
>
{{ item.name }}
</CommonDropdownItem>
</template>
</CommonDropdown>
</template>