feat(landing): Change language switcher
This commit is contained in:
@@ -40,14 +40,22 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<template #right>
|
<template #right>
|
||||||
<USelectMenu
|
<UDropdownMenu
|
||||||
v-model="selectedLocale"
|
:items="localeMenuItems"
|
||||||
:items="localeItems"
|
:modal="false"
|
||||||
class="w-[90px] sm:w-[100px]"
|
:ui="{ content: 'min-w-32' }"
|
||||||
:ui="{
|
:content="{
|
||||||
base: 'text-sm'
|
align: 'end'
|
||||||
}"
|
}"
|
||||||
/>
|
>
|
||||||
|
<UButton
|
||||||
|
icon="i-lucide-globe"
|
||||||
|
color="neutral"
|
||||||
|
variant="ghost"
|
||||||
|
:aria-label="$t('common.changeLanguage')"
|
||||||
|
class="text-gray-600 dark:text-gray-300 hover:text-primary-600 dark:hover:text-primary-400"
|
||||||
|
/>
|
||||||
|
</UDropdownMenu>
|
||||||
<UColorModeButton
|
<UColorModeButton
|
||||||
:ui="{
|
:ui="{
|
||||||
base: 'text-gray-600 dark:text-gray-300 hover:text-primary-600 dark:hover:text-primary-400'
|
base: 'text-gray-600 dark:text-gray-300 hover:text-primary-600 dark:hover:text-primary-400'
|
||||||
@@ -176,28 +184,20 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { NavigationMenuItem } from '@nuxt/ui'
|
import type { NavigationMenuItem, DropdownMenuItem } from '@nuxt/ui'
|
||||||
|
|
||||||
const { t, locale, locales, setLocale } = useI18n()
|
const { t, locale, locales, setLocale } = useI18n()
|
||||||
|
|
||||||
// Locale selector items
|
// Locale dropdown menu items
|
||||||
const localeItems = computed(() =>
|
const localeMenuItems = computed<DropdownMenuItem[]>(() =>
|
||||||
(locales.value as Array<{ code: string; name: string }>).map((l) => ({
|
(locales.value as Array<{ code: string; name: string }>).map((l) => ({
|
||||||
label: l.name,
|
label: l.name,
|
||||||
value: l.code
|
icon: locale.value === l.code ? 'i-lucide-check' : undefined,
|
||||||
|
active: locale.value === l.code,
|
||||||
|
onSelect: () => setLocale(l.code as 'en' | 'de')
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
|
|
||||||
// Selected locale for the dropdown
|
|
||||||
const selectedLocale = computed({
|
|
||||||
get: () => localeItems.value.find((l) => l.value === locale.value),
|
|
||||||
set: (item) => {
|
|
||||||
if (item) {
|
|
||||||
setLocale(item.value as 'en' | 'de')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Track scroll position for header styling
|
// Track scroll position for header styling
|
||||||
const isScrolled = ref(false)
|
const isScrolled = ref(false)
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
},
|
},
|
||||||
"common": {
|
"common": {
|
||||||
"skipToContent": "Zum Hauptinhalt springen",
|
"skipToContent": "Zum Hauptinhalt springen",
|
||||||
|
"changeLanguage": "Sprache ändern",
|
||||||
"stayInformed": "Informiert bleiben",
|
"stayInformed": "Informiert bleiben",
|
||||||
"learnMore": "Mehr erfahren",
|
"learnMore": "Mehr erfahren",
|
||||||
"contact": "Kontakt aufnehmen",
|
"contact": "Kontakt aufnehmen",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
},
|
},
|
||||||
"common": {
|
"common": {
|
||||||
"skipToContent": "Skip to main content",
|
"skipToContent": "Skip to main content",
|
||||||
|
"changeLanguage": "Change language",
|
||||||
"stayInformed": "Stay informed",
|
"stayInformed": "Stay informed",
|
||||||
"learnMore": "Learn more",
|
"learnMore": "Learn more",
|
||||||
"contact": "Contact us",
|
"contact": "Contact us",
|
||||||
|
|||||||
Reference in New Issue
Block a user