29 lines
795 B
Vue
29 lines
795 B
Vue
<script setup lang="ts">
|
|
const { locale, locales, t } = useI18n();
|
|
|
|
const switchLocalePath = useSwitchLocalePath();
|
|
const availableLocales = computed(() => {
|
|
return locales.value.filter((i) => i.code !== locale.value);
|
|
});
|
|
|
|
function l(locale: (typeof locales.value)[0]) {
|
|
return typeof locale === 'string' ? locale : locale.code;
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<VaSidebarItem
|
|
v-for="loc in availableLocales"
|
|
:key="loc.code"
|
|
:to="switchLocalePath(loc.code)"
|
|
:title="t('layouts.switch_lang', { locale: t(`locales.${l(loc)}`) })"
|
|
>
|
|
<VaSidebarItemContent>
|
|
<VaIcon name="language" />
|
|
<VaSidebarItemTitle>
|
|
{{ t('layouts.switch_lang', { locale: t(`locales.${l(loc)}`) }) }}
|
|
</VaSidebarItemTitle>
|
|
</VaSidebarItemContent>
|
|
</VaSidebarItem>
|
|
</template>
|