chore: separate frontend from backend
This commit is contained in:
26
app/components/navbar/LanguageSwitcher.vue
Normal file
26
app/components/navbar/LanguageSwitcher.vue
Normal file
@@ -0,0 +1,26 @@
|
||||
<template>
|
||||
<UDropdownMenu :key="locale" :items="availableLocales" :content="{ align: 'start' }">
|
||||
<UButton color="neutral" variant="outline" icon="material-symbols:globe" :aria-label="$t('menu.language')" />
|
||||
</UDropdownMenu>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { DropdownMenuItem } from '@nuxt/ui';
|
||||
const { locale, locales, setLocale } = useI18n();
|
||||
|
||||
const availableLocales = computed(() => {
|
||||
return locales.value.map(
|
||||
(optionLocale) =>
|
||||
({
|
||||
label: optionLocale.name,
|
||||
code: optionLocale.code,
|
||||
type: 'checkbox' as const,
|
||||
checked: optionLocale.code === locale.value,
|
||||
onUpdateChecked: () => switchLocale(optionLocale.code),
|
||||
}) as DropdownMenuItem,
|
||||
);
|
||||
});
|
||||
const switchLocale = (newLocale: string) => {
|
||||
setLocale(newLocale);
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user