Remove i18n, keep only Italian and rely on browser translation
The interface was translated in en/it/es/fr via @nuxtjs/i18n. Drop the module, the locale files, and the language switcher: the UI is now static Italian text, with translation for foreign visitors left to the Google Translate browser extension instead of the app.
This commit is contained in:
@@ -3,7 +3,6 @@ import type { ArticleSummary } from '#shared/types/blog'
|
||||
|
||||
const props = defineProps<{ article: ArticleSummary }>()
|
||||
|
||||
const { locale } = useI18n()
|
||||
const mediaUrl = useMediaUrl()
|
||||
const cover = computed(() => mediaUrl(props.article.cover))
|
||||
</script>
|
||||
@@ -12,7 +11,7 @@ const cover = computed(() => mediaUrl(props.article.cover))
|
||||
<article class="card">
|
||||
<!-- No placeholder box when there is no cover: an empty grey rectangle
|
||||
reads as a broken image rather than as a deliberate choice. -->
|
||||
<NuxtLinkLocale
|
||||
<NuxtLink
|
||||
v-if="cover"
|
||||
class="cover-link"
|
||||
:to="`/blog/${article.slug}`"
|
||||
@@ -27,17 +26,17 @@ const cover = computed(() => mediaUrl(props.article.cover))
|
||||
:height="article.cover?.height ?? undefined"
|
||||
loading="lazy"
|
||||
>
|
||||
</NuxtLinkLocale>
|
||||
</NuxtLink>
|
||||
|
||||
<p v-if="article.category" class="kicker">{{ article.category.name }}</p>
|
||||
|
||||
<h2>
|
||||
<NuxtLinkLocale :to="`/blog/${article.slug}`">{{ article.title }}</NuxtLinkLocale>
|
||||
<NuxtLink :to="`/blog/${article.slug}`">{{ article.title }}</NuxtLink>
|
||||
</h2>
|
||||
|
||||
<p class="kicker date">
|
||||
<time :datetime="isoDate(article.publishedAt)">
|
||||
{{ formatDate(article.publishedAt, locale) }}
|
||||
{{ formatDate(article.publishedAt) }}
|
||||
</time>
|
||||
</p>
|
||||
</article>
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
const { locale, locales, t } = useI18n()
|
||||
const switchLocalePath = useSwitchLocalePath()
|
||||
const router = useRouter()
|
||||
|
||||
/**
|
||||
* A native select: it gets keyboard support, the platform picker on mobile and
|
||||
* correct labelling for free, which a hand-built dropdown would have to rebuild.
|
||||
*/
|
||||
function onChange(event: Event) {
|
||||
const code = (event.target as HTMLSelectElement).value as typeof locale.value
|
||||
const path = switchLocalePath(code)
|
||||
if (path) router.push(path)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="switcher">
|
||||
<label class="visually-hidden" for="locale-select">{{ t('site.languageLabel') }}</label>
|
||||
<select id="locale-select" :value="locale" @change="onChange">
|
||||
<option v-for="option in locales" :key="option.code" :value="option.code">
|
||||
{{ option.name }}
|
||||
</option>
|
||||
</select>
|
||||
<span class="arrow" aria-hidden="true">▾</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.switcher {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
select {
|
||||
appearance: none;
|
||||
padding: 0.4rem 1.7rem 0.4rem 0.7rem;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
color: var(--color-body);
|
||||
font: inherit;
|
||||
/* Safari on iOS zooms the page when a control smaller than 16px is tapped,
|
||||
so the picker stays at 1rem on phones and shrinks only from tablet up. */
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.14em;
|
||||
text-transform: uppercase;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@media (min-width: 48rem) {
|
||||
select {
|
||||
padding: 0.35rem 1.6rem 0.35rem 0.7rem;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
select:hover {
|
||||
border-color: var(--color-ink);
|
||||
color: var(--color-ink);
|
||||
}
|
||||
|
||||
.arrow {
|
||||
position: absolute;
|
||||
right: 0.6rem;
|
||||
font-size: 0.65rem;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.visually-hidden {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user