The interface is translated through @nuxtjs/i18n: strings live in i18n/locales/*.json, routes are prefixed except for the default English, and useLocaleHead emits the lang attribute, the hreflang alternates and og:locale. The switcher is a native select rather than a custom dropdown: keyboard support, the platform picker on mobile and correct labelling come for free. Article content stays single-language — this translates the site chrome only.
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import { SITE_NAME } from './shared/utils/site'
|
|
|
|
// https://nuxt.com/docs/api/configuration/nuxt-config
|
|
export default defineNuxtConfig({
|
|
compatibilityDate: '2025-07-15',
|
|
devtools: { enabled: true },
|
|
|
|
modules: ['@nuxtjs/i18n'],
|
|
|
|
css: ['~/assets/css/main.css'],
|
|
|
|
app: {
|
|
head: {
|
|
titleTemplate: `%s · ${SITE_NAME}`,
|
|
meta: [{ name: 'viewport', content: 'width=device-width, initial-scale=1' }],
|
|
link: [
|
|
{ rel: 'icon', href: '/favicon.ico', sizes: '16x16 32x32 48x48 64x64' },
|
|
{ rel: 'apple-touch-icon', href: '/apple-touch-icon.png' },
|
|
],
|
|
},
|
|
},
|
|
|
|
i18n: {
|
|
// English keeps the bare URLs; the others are prefixed (/it/blog, /es/blog…).
|
|
defaultLocale: 'en',
|
|
strategy: 'prefix_except_default',
|
|
locales: [
|
|
{ code: 'en', language: 'en-GB', name: 'English', file: 'en.json' },
|
|
{ code: 'it', language: 'it-IT', name: 'Italiano', file: 'it.json' },
|
|
{ code: 'es', language: 'es-ES', name: 'Español', file: 'es.json' },
|
|
{ code: 'fr', language: 'fr-FR', name: 'Français', file: 'fr.json' },
|
|
],
|
|
// First visit follows the browser language; after that the cookie wins.
|
|
detectBrowserLanguage: {
|
|
useCookie: true,
|
|
cookieKey: 'locale',
|
|
redirectOn: 'root',
|
|
},
|
|
// Overridden per environment with NUXT_PUBLIC_I18N_BASE_URL, so the
|
|
// alternate-language links are absolute and correct in production.
|
|
baseUrl: 'http://localhost:3000',
|
|
},
|
|
|
|
runtimeConfig: {
|
|
// Server-only: internal Strapi address, never exposed to the browser.
|
|
strapiUrl: 'http://localhost:1337',
|
|
strapiToken: '',
|
|
public: {
|
|
// Canonical origin of the public website.
|
|
siteUrl: 'http://localhost:3000',
|
|
// Browser-reachable Strapi origin, used to build absolute media URLs.
|
|
strapiUrl: 'http://localhost:1337',
|
|
},
|
|
},
|
|
|
|
typescript: {
|
|
strict: true,
|
|
},
|
|
})
|