Merge pull request 'feat(i18n): add five locales and a header language switcher' (#17) from feat/language_support into main
release-please / release-please (push) Successful in 8s
release-please / release-please (push) Successful in 8s
Reviewed-on: #17
This commit was merged in pull request #17.
This commit is contained in:
commit
ce941cad2d
16 files changed
+1379
-20
No files matched your search
@@ -4,27 +4,26 @@
|
|||||||
class="fixed bottom-0 left-0 w-full z-50 flex md:hidden bg-surface-container-low/90 backdrop-blur-xl shadow-[0_-1px_12px_rgba(0,0,0,0.3)]"
|
class="fixed bottom-0 left-0 w-full z-50 flex md:hidden bg-surface-container-low/90 backdrop-blur-xl shadow-[0_-1px_12px_rgba(0,0,0,0.3)]"
|
||||||
>
|
>
|
||||||
<div class="w-full h-16 px-space-xs flex items-center justify-around">
|
<div class="w-full h-16 px-space-xs flex items-center justify-around">
|
||||||
<NuxtLink
|
<NuxtLinkLocale
|
||||||
to="/"
|
to="/"
|
||||||
aria-current="page"
|
|
||||||
class="w-16 h-12 flex flex-col items-center justify-center text-primary font-semibold transition-colors"
|
class="w-16 h-12 flex flex-col items-center justify-center text-primary font-semibold transition-colors"
|
||||||
>
|
>
|
||||||
<Icon name="material-symbols:badge" aria-hidden="true" class="text-[22px]" />
|
<Icon name="material-symbols:badge" aria-hidden="true" class="text-[22px]" />
|
||||||
<span class="font-label-mono text-label-mono">Overview</span>
|
<span class="font-label-mono text-label-mono">{{ $t('nav.overview') }}</span>
|
||||||
</NuxtLink>
|
</NuxtLinkLocale>
|
||||||
<a
|
<a
|
||||||
href="#"
|
href="#"
|
||||||
class="w-16 h-12 flex flex-col items-center justify-center text-on-surface-variant hover:text-primary transition-colors"
|
class="w-16 h-12 flex flex-col items-center justify-center text-on-surface-variant hover:text-primary transition-colors"
|
||||||
>
|
>
|
||||||
<Icon name="material-symbols:timeline" aria-hidden="true" class="text-[22px]" />
|
<Icon name="material-symbols:timeline" aria-hidden="true" class="text-[22px]" />
|
||||||
<span class="font-label-mono text-label-mono">Life Map</span>
|
<span class="font-label-mono text-label-mono">{{ $t('nav.lifeMap') }}</span>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
href="#"
|
href="#"
|
||||||
class="w-16 h-12 flex flex-col items-center justify-center text-on-surface-variant hover:text-primary transition-colors"
|
class="w-16 h-12 flex flex-col items-center justify-center text-on-surface-variant hover:text-primary transition-colors"
|
||||||
>
|
>
|
||||||
<Icon name="material-symbols:code" aria-hidden="true" class="text-[22px]" />
|
<Icon name="material-symbols:code" aria-hidden="true" class="text-[22px]" />
|
||||||
<span class="font-label-mono text-label-mono">Dev View</span>
|
<span class="font-label-mono text-label-mono">{{ $t('nav.devView') }}</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
defineProps<{ code: 'en' | 'de' | 'es' | 'it' | 'pl' }>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<svg v-if="code === 'en'" viewBox="0 0 24 16" class="h-full w-full" aria-hidden="true">
|
||||||
|
<rect width="24" height="16" fill="#012169" />
|
||||||
|
<path d="M0 0 24 16 M24 0 0 16" stroke="#fff" stroke-width="3.2" />
|
||||||
|
<path d="M0 0 24 16 M24 0 0 16" stroke="#c8102e" stroke-width="1.6" />
|
||||||
|
<rect x="10.4" width="3.2" height="16" fill="#fff" />
|
||||||
|
<rect y="6.4" width="24" height="3.2" fill="#fff" />
|
||||||
|
<rect x="11" width="2" height="16" fill="#c8102e" />
|
||||||
|
<rect y="7" width="24" height="2" fill="#c8102e" />
|
||||||
|
</svg>
|
||||||
|
<svg v-else-if="code === 'de'" viewBox="0 0 24 16" class="h-full w-full" aria-hidden="true">
|
||||||
|
<rect width="24" height="5.334" fill="#000" />
|
||||||
|
<rect y="5.334" width="24" height="5.333" fill="#dd0000" />
|
||||||
|
<rect y="10.667" width="24" height="5.333" fill="#ffce00" />
|
||||||
|
</svg>
|
||||||
|
<svg v-else-if="code === 'es'" viewBox="0 0 24 16" class="h-full w-full" aria-hidden="true">
|
||||||
|
<rect width="24" height="16" fill="#aa151b" />
|
||||||
|
<rect y="4" width="24" height="8" fill="#f1bf00" />
|
||||||
|
</svg>
|
||||||
|
<svg v-else-if="code === 'it'" viewBox="0 0 24 16" class="h-full w-full" aria-hidden="true">
|
||||||
|
<rect width="8" height="16" fill="#008c45" />
|
||||||
|
<rect x="8" width="8" height="16" fill="#f4f5f0" />
|
||||||
|
<rect x="16" width="8" height="16" fill="#cd212a" />
|
||||||
|
</svg>
|
||||||
|
<svg v-else viewBox="0 0 24 16" class="h-full w-full" aria-hidden="true">
|
||||||
|
<rect width="24" height="8" fill="#fff" />
|
||||||
|
<rect y="8" width="24" height="8" fill="#dc143c" />
|
||||||
|
</svg>
|
||||||
|
</template>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<div class="max-w-7xl mx-auto px-6 lg:px-12 flex flex-col sm:flex-row items-center justify-between gap-4">
|
<div class="max-w-7xl mx-auto px-6 lg:px-12 flex flex-col sm:flex-row items-center justify-between gap-4">
|
||||||
<div class="flex items-center gap-2.5 font-label-mono text-label-mono text-on-surface-variant">
|
<div class="flex items-center gap-2.5 font-label-mono text-label-mono text-on-surface-variant">
|
||||||
<span class="inline-block w-2 h-2 rounded-full bg-secondary shadow-[0_0_6px_#4ae176]" />
|
<span class="inline-block w-2 h-2 rounded-full bg-secondary shadow-[0_0_6px_#4ae176]" />
|
||||||
<span>Served from my own server · k8s · Terraform · self-healing on purpose</span>
|
<span>{{ $t('footer.servedFrom') }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-3 font-status-badge text-status-badge text-outline">
|
<div class="flex items-center gap-3 font-status-badge text-status-badge text-outline">
|
||||||
<a
|
<a
|
||||||
|
|||||||
@@ -3,7 +3,11 @@
|
|||||||
<div class="h-16 max-w-7xl mx-auto px-6 lg:px-12 flex items-center justify-between gap-6">
|
<div class="h-16 max-w-7xl mx-auto px-6 lg:px-12 flex items-center justify-between gap-6">
|
||||||
<AppLogo />
|
<AppLogo />
|
||||||
<AppNav />
|
<AppNav />
|
||||||
<AppQuickLinks />
|
<div class="flex items-center gap-4">
|
||||||
|
<AppQuickLinks />
|
||||||
|
<span class="hidden sm:inline text-[0.625rem] text-outline-variant" aria-hidden="true">/</span>
|
||||||
|
<AppLanguageSwitcher />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
</template>
|
</template>
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
const { locales, locale, setLocale, t } = useI18n()
|
||||||
|
|
||||||
|
const open = ref(false)
|
||||||
|
const root = ref<HTMLElement | null>(null)
|
||||||
|
const trigger = ref<HTMLButtonElement | null>(null)
|
||||||
|
const menuId = useId()
|
||||||
|
|
||||||
|
// The accessible name has to contain the visible text (WCAG 2.5.3).
|
||||||
|
const triggerLabel = computed(() => `${t('switcher.label')}: ${locale.value.toUpperCase()}`)
|
||||||
|
|
||||||
|
function closeOnOutside(event: MouseEvent) {
|
||||||
|
if (!root.value?.contains(event.target as Node)) {
|
||||||
|
open.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeOnEscape(event: KeyboardEvent) {
|
||||||
|
if (event.key === 'Escape' && open.value) {
|
||||||
|
open.value = false
|
||||||
|
// Focus would otherwise stay on a list item that just left the DOM.
|
||||||
|
trigger.value?.focus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
document.addEventListener('click', closeOnOutside)
|
||||||
|
document.addEventListener('keydown', closeOnEscape)
|
||||||
|
})
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
document.removeEventListener('click', closeOnOutside)
|
||||||
|
document.removeEventListener('keydown', closeOnEscape)
|
||||||
|
})
|
||||||
|
|
||||||
|
async function choose(code: Parameters<typeof setLocale>[0]) {
|
||||||
|
open.value = false
|
||||||
|
await setLocale(code)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div ref="root" class="relative flex shrink-0 items-center font-label-mono text-label-mono">
|
||||||
|
<button
|
||||||
|
ref="trigger"
|
||||||
|
type="button"
|
||||||
|
class="flex items-center gap-1.5 uppercase tracking-wider text-on-surface-variant transition-colors hover:text-on-surface"
|
||||||
|
:aria-expanded="open"
|
||||||
|
:aria-controls="menuId"
|
||||||
|
:aria-label="triggerLabel"
|
||||||
|
@click="open = !open"
|
||||||
|
>
|
||||||
|
<span class="h-3.5 w-5 overflow-hidden rounded-[2px]">
|
||||||
|
<AppFlag :code="locale" />
|
||||||
|
</span>
|
||||||
|
<span>{{ locale }}</span>
|
||||||
|
<span aria-hidden="true" class="text-[0.625rem] text-on-surface-variant">▼</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<ul
|
||||||
|
v-if="open"
|
||||||
|
:id="menuId"
|
||||||
|
class="absolute right-0 top-full z-10 mt-2 min-w-48 rounded-lg border border-outline-variant/30 bg-surface-container-high p-1 shadow-lg"
|
||||||
|
>
|
||||||
|
<li v-for="language in locales" :key="language.code">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="flex w-full items-center gap-3 rounded px-3 py-2 text-left transition-colors"
|
||||||
|
:class="locale === language.code
|
||||||
|
? 'bg-surface-variant text-on-surface'
|
||||||
|
: 'text-on-surface-variant hover:bg-surface-variant hover:text-on-surface'"
|
||||||
|
:aria-current="locale === language.code ? 'true' : undefined"
|
||||||
|
@click="choose(language.code)"
|
||||||
|
>
|
||||||
|
<span class="h-3.5 w-5 shrink-0 overflow-hidden rounded-[2px]">
|
||||||
|
<AppFlag :code="language.code" />
|
||||||
|
</span>
|
||||||
|
<span class="flex-1">{{ language.name }}</span>
|
||||||
|
<span class="uppercase tracking-wider">{{ language.code }}</span>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -9,7 +9,7 @@ const flat = AVATAR_SPRITE
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<NuxtLink to="/" class="group flex items-center gap-3">
|
<NuxtLinkLocale to="/" class="group flex items-center gap-3">
|
||||||
<span class="flex items-center justify-center w-8 h-8 rounded bg-surface-container-high transition-colors">
|
<span class="flex items-center justify-center w-8 h-8 rounded bg-surface-container-high transition-colors">
|
||||||
<span class="pixel-avatar" aria-hidden="true">
|
<span class="pixel-avatar" aria-hidden="true">
|
||||||
<span
|
<span
|
||||||
@@ -24,7 +24,7 @@ const flat = AVATAR_SPRITE
|
|||||||
<span class="font-headline-sm text-headline-sm tracking-tight text-on-surface font-medium">Noel Sabia</span>
|
<span class="font-headline-sm text-headline-sm tracking-tight text-on-surface font-medium">Noel Sabia</span>
|
||||||
<span class="font-label-mono text-label-mono text-on-surface-variant tracking-wider uppercase text-[0.625rem]">Im using Arch btw</span>
|
<span class="font-label-mono text-label-mono text-on-surface-variant tracking-wider uppercase text-[0.625rem]">Im using Arch btw</span>
|
||||||
</div>
|
</div>
|
||||||
</NuxtLink>
|
</NuxtLinkLocale>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -1,23 +1,22 @@
|
|||||||
<template>
|
<template>
|
||||||
<nav class="hidden md:flex items-center gap-1.5">
|
<nav class="hidden lg:flex items-center gap-1.5">
|
||||||
<NuxtLink
|
<NuxtLinkLocale
|
||||||
to="/"
|
to="/"
|
||||||
aria-current="page"
|
|
||||||
class="px-3 py-1.5 transition-colors bg-primary-container text-on-primary-container font-medium rounded font-body-sm text-body-sm"
|
class="px-3 py-1.5 transition-colors bg-primary-container text-on-primary-container font-medium rounded font-body-sm text-body-sm"
|
||||||
>
|
>
|
||||||
Overview
|
{{ $t('nav.overview') }}
|
||||||
</NuxtLink>
|
</NuxtLinkLocale>
|
||||||
<a
|
<a
|
||||||
href="#"
|
href="#"
|
||||||
class="px-3 py-1.5 text-on-surface-variant hover:text-on-surface hover:bg-surface-container-high transition-colors font-body-sm text-body-sm"
|
class="px-3 py-1.5 text-on-surface-variant hover:text-on-surface hover:bg-surface-container-high transition-colors font-body-sm text-body-sm"
|
||||||
>
|
>
|
||||||
Life Map
|
{{ $t('nav.lifeMap') }}
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
href="#"
|
href="#"
|
||||||
class="px-3 py-1.5 text-on-surface-variant hover:text-on-surface hover:bg-surface-container-high transition-colors font-body-sm text-body-sm"
|
class="px-3 py-1.5 text-on-surface-variant hover:text-on-surface hover:bg-surface-container-high transition-colors font-body-sm text-body-sm"
|
||||||
>
|
>
|
||||||
Dev View
|
{{ $t('nav.devView') }}
|
||||||
</a>
|
</a>
|
||||||
</nav>
|
</nav>
|
||||||
</template>
|
</template>
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="hidden sm:flex items-center gap-4 text-on-surface-variant font-label-mono text-label-mono">
|
<div class="hidden sm:flex items-center gap-4 text-on-surface-variant font-label-mono text-label-mono">
|
||||||
<a href="#" class="hover:text-on-surface transition-colors">PDF CV</a>
|
<a href="#" class="hover:text-on-surface transition-colors">{{ $t('quickLinks.pdfCv') }}</a>
|
||||||
<span class="text-outline-variant text-[0.625rem]">/</span>
|
<span class="text-outline-variant text-[0.625rem]">/</span>
|
||||||
<a href="#" class="hover:text-on-surface transition-colors">Contact</a>
|
<a href="#" class="hover:text-on-surface transition-colors">{{ $t('quickLinks.contact') }}</a>
|
||||||
<span class="text-outline-variant text-[0.625rem]">/</span>
|
<span class="text-outline-variant text-[0.625rem]">/</span>
|
||||||
<a href="https://github.com/NoelSabia" rel="noopener noreferrer" target="_blank" class="hover:text-on-surface transition-colors">GitHub</a>
|
<a href="https://github.com/NoelSabia" rel="noopener noreferrer" target="_blank" class="hover:text-on-surface transition-colors">GitHub</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"nav": {
|
||||||
|
"overview": "Übersicht",
|
||||||
|
"lifeMap": "Lebenskarte",
|
||||||
|
"devView": "Dev-Ansicht"
|
||||||
|
},
|
||||||
|
"quickLinks": {
|
||||||
|
"pdfCv": "Lebenslauf (PDF)",
|
||||||
|
"contact": "Kontakt"
|
||||||
|
},
|
||||||
|
"footer": {
|
||||||
|
"servedFrom": "Betrieben auf meinem eigenen Server · k8s · Terraform"
|
||||||
|
},
|
||||||
|
"switcher": {
|
||||||
|
"label": "Sprache"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"nav": {
|
||||||
|
"overview": "Overview",
|
||||||
|
"lifeMap": "Life Map",
|
||||||
|
"devView": "Dev View"
|
||||||
|
},
|
||||||
|
"quickLinks": {
|
||||||
|
"pdfCv": "PDF CV",
|
||||||
|
"contact": "Contact"
|
||||||
|
},
|
||||||
|
"footer": {
|
||||||
|
"servedFrom": "Served from my own server · k8s · Terraform"
|
||||||
|
},
|
||||||
|
"switcher": {
|
||||||
|
"label": "Language"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"nav": {
|
||||||
|
"overview": "Resumen",
|
||||||
|
"lifeMap": "Mapa de vida",
|
||||||
|
"devView": "Vista dev"
|
||||||
|
},
|
||||||
|
"quickLinks": {
|
||||||
|
"pdfCv": "CV en PDF",
|
||||||
|
"contact": "Contacto"
|
||||||
|
},
|
||||||
|
"footer": {
|
||||||
|
"servedFrom": "Servido desde mi propio servidor · k8s · Terraform"
|
||||||
|
},
|
||||||
|
"switcher": {
|
||||||
|
"label": "Idioma"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"nav": {
|
||||||
|
"overview": "Panoramica",
|
||||||
|
"lifeMap": "Mappa della vita",
|
||||||
|
"devView": "Vista dev"
|
||||||
|
},
|
||||||
|
"quickLinks": {
|
||||||
|
"pdfCv": "CV in PDF",
|
||||||
|
"contact": "Contatti"
|
||||||
|
},
|
||||||
|
"footer": {
|
||||||
|
"servedFrom": "Servito dal mio server · k8s · Terraform"
|
||||||
|
},
|
||||||
|
"switcher": {
|
||||||
|
"label": "Lingua"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"nav": {
|
||||||
|
"overview": "Przegląd",
|
||||||
|
"lifeMap": "Mapa życia",
|
||||||
|
"devView": "Widok dev"
|
||||||
|
},
|
||||||
|
"quickLinks": {
|
||||||
|
"pdfCv": "CV w PDF",
|
||||||
|
"contact": "Kontakt"
|
||||||
|
},
|
||||||
|
"footer": {
|
||||||
|
"servedFrom": "Hostowane na moim serwerze · k8s · Terraform"
|
||||||
|
},
|
||||||
|
"switcher": {
|
||||||
|
"label": "Język"
|
||||||
|
}
|
||||||
|
}
|
||||||
+13
-1
@@ -4,7 +4,7 @@ import { SITE } from './site.config.mjs'
|
|||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
compatibilityDate: '2025-07-15',
|
compatibilityDate: '2025-07-15',
|
||||||
devtools: { enabled: true },
|
devtools: { enabled: true },
|
||||||
modules: ['@nuxt/eslint', '@nuxtjs/tailwindcss', '@nuxt/icon/module', '@nuxtjs/seo'],
|
modules: ['@nuxt/eslint', '@nuxtjs/tailwindcss', '@nuxt/icon/module', '@nuxtjs/seo', '@nuxtjs/i18n'],
|
||||||
// Shared by sitemap, robots, canonical URLs, Open Graph and schema.org.
|
// Shared by sitemap, robots, canonical URLs, Open Graph and schema.org.
|
||||||
site: {
|
site: {
|
||||||
url: SITE.url,
|
url: SITE.url,
|
||||||
@@ -55,5 +55,17 @@ export default defineNuxtConfig({
|
|||||||
},
|
},
|
||||||
tailwindcss: {
|
tailwindcss: {
|
||||||
cssPath: '~/assets/css/main.css'
|
cssPath: '~/assets/css/main.css'
|
||||||
|
},
|
||||||
|
i18n: {
|
||||||
|
// Absolute URLs for hreflang and the per-locale sitemaps.
|
||||||
|
baseUrl: SITE.url,
|
||||||
|
defaultLocale: 'en',
|
||||||
|
locales: [
|
||||||
|
{ code: 'en', language: 'en', name: 'English', file: 'en.json' },
|
||||||
|
{ code: 'de', language: 'de', name: 'Deutsch', file: 'de.json' },
|
||||||
|
{ code: 'es', language: 'es', name: 'Español', file: 'es.json' },
|
||||||
|
{ code: 'it', language: 'it', name: 'Italiano', file: 'it.json' },
|
||||||
|
{ code: 'pl', language: 'pl', name: 'Polski', file: 'pl.json' }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@iconify-json/material-symbols": "^1.2.95",
|
"@iconify-json/material-symbols": "^1.2.95",
|
||||||
"@nuxt/icon": "2.6.0",
|
"@nuxt/icon": "2.6.0",
|
||||||
|
"@nuxtjs/i18n": "10.6.0",
|
||||||
"@nuxtjs/seo": "6.0.1",
|
"@nuxtjs/seo": "6.0.1",
|
||||||
"@nuxtjs/tailwindcss": "6.14.0",
|
"@nuxtjs/tailwindcss": "6.14.0",
|
||||||
"nuxt": "^4.6.2",
|
"nuxt": "^4.6.2",
|
||||||
|
|||||||
Generated
+1142
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user