2026-09-11 13:52:13 +02:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { STRINGS } from '#shared/utils/i18n'
|
|
|
|
|
import { bareLocalePath, localePath } from '#shared/utils/locale'
|
2026-09-11 14:31:58 +02:00
|
|
|
import type { Locale } from '#shared/utils/locale'
|
2026-09-11 13:52:13 +02:00
|
|
|
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
const locale = useLocale()
|
|
|
|
|
const langSwitch = useLangSwitchState()
|
|
|
|
|
|
2026-09-11 14:31:58 +02:00
|
|
|
const strings = computed(() => STRINGS[locale.value])
|
2026-09-11 13:52:13 +02:00
|
|
|
|
2026-09-11 14:31:58 +02:00
|
|
|
function targetFor(otherLocale: Locale): string {
|
|
|
|
|
if (!langSwitch.value.available) return langSwitch.value.fallback
|
|
|
|
|
return localePath(otherLocale, bareLocalePath(route.path))
|
|
|
|
|
}
|
2026-09-11 13:52:13 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2026-09-11 14:31:58 +02:00
|
|
|
<div class="lang-switch" :aria-label="strings.langSwitch.ariaLabel" role="group">
|
|
|
|
|
<span v-if="locale === 'it'" class="lang-option is-current" aria-current="true">
|
|
|
|
|
{{ strings.langSwitch.it }}
|
|
|
|
|
</span>
|
|
|
|
|
<NuxtLink v-else class="lang-option" :to="targetFor('it')">
|
|
|
|
|
{{ strings.langSwitch.it }}
|
|
|
|
|
</NuxtLink>
|
|
|
|
|
|
|
|
|
|
<span class="lang-divider" aria-hidden="true">/</span>
|
|
|
|
|
|
|
|
|
|
<span v-if="locale === 'en'" class="lang-option is-current" aria-current="true">
|
|
|
|
|
{{ strings.langSwitch.en }}
|
|
|
|
|
</span>
|
|
|
|
|
<NuxtLink v-else class="lang-option" :to="targetFor('en')">
|
|
|
|
|
{{ strings.langSwitch.en }}
|
|
|
|
|
</NuxtLink>
|
|
|
|
|
</div>
|
2026-09-11 13:52:13 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.lang-switch {
|
2026-09-11 14:31:58 +02:00
|
|
|
display: inline-flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 0.4rem;
|
|
|
|
|
font-size: 0.7rem;
|
2026-09-11 13:52:13 +02:00
|
|
|
font-weight: 600;
|
2026-09-11 14:31:58 +02:00
|
|
|
letter-spacing: 0.1em;
|
2026-09-11 13:52:13 +02:00
|
|
|
text-transform: uppercase;
|
2026-09-11 14:31:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.lang-option {
|
|
|
|
|
display: inline-block;
|
2026-09-11 13:52:13 +02:00
|
|
|
text-decoration: none;
|
2026-09-11 14:31:58 +02:00
|
|
|
color: var(--color-muted);
|
|
|
|
|
padding-block: 0.25rem;
|
2026-09-11 13:52:13 +02:00
|
|
|
border-bottom: 1px solid transparent;
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-11 14:31:58 +02:00
|
|
|
a.lang-option:hover,
|
|
|
|
|
a.lang-option:focus-visible {
|
|
|
|
|
color: var(--color-ink);
|
2026-09-11 13:52:13 +02:00
|
|
|
border-bottom-color: var(--color-ink);
|
|
|
|
|
}
|
2026-09-11 14:31:58 +02:00
|
|
|
|
|
|
|
|
.lang-option.is-current {
|
|
|
|
|
color: var(--color-ink);
|
|
|
|
|
border-bottom-color: var(--color-ink);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.lang-divider {
|
|
|
|
|
color: var(--color-border);
|
|
|
|
|
}
|
2026-09-11 13:52:13 +02:00
|
|
|
</style>
|