Internationalization

Translating the UI, categories, cookies, and links.

Internationalization

The module ships defaults for English, German, Spanish, and French, and lets you override or extend any string. Your texts are deep-merged over the built-ins, so you only specify what you change.

Switching locale

Set the initial locale with locale, and switch at runtime:

const { $consent } = useNuxtApp()
$consent.setLocale('de')

Missing keys fall back to fallbackLocale.

Text structure

Each locale follows this shape:

{
  en: {
    bannerTitle: 'Cookie Consent',
    bannerDescription: 'We use cookies… Learn more in our {privacy}.',
    modalTitle: 'Cookie Consent Settings',
    modalDescription: '…{privacy} and {imprint}.',
    contextMessage: 'To use this feature, please grant consent for {categoryName}.',
    acceptAllBtn: 'Accept All',
    acceptSelectionBtn: 'Save Preferences',
    customizeBtn: 'Customize',
    cookieId: 'Name',
    cookieProvider: 'Provider',
    cookieDuration: 'Duration',
    links: {
      privacy: 'Privacy Policy',
      imprint: 'Imprint',
    },
    categories: {
      necessary: { name: 'Necessary Cookies', description: '…' },
      analytics: { name: 'Analytics Cookies', description: '…' },
      // …one entry per category key you define
    },
    // your per-cookie descriptions, referenced by `descriptionKey`
    cookies: {
      analytics: { ga: { description: 'Used by Google Analytics…' } },
    },
  },
}

Placeholders in text (e.g. {privacy}, {imprint}) are turned into links:

  • The label comes from texts[locale].links[key].
  • The href comes from linkMap[key] (configured globally), or a per-locale texts[locale].linkMap[key] if you need locale-specific URLs.
cookieConsent: {
  linkMap: { privacy: '/privacy-policy', imprint: '/imprint' },
}

Providers, durations and category descriptions

A cookie's provider and duration, and a category's description, are written in the config itself. Give one string for every locale, or one per locale:

cookies: [{
  id: '_ga',
  descriptionKey: 'cookies.analytics.ga.description',
  provider: 'Google LLC',                        // the same in every language
  duration: { en: '2 years', de: '2 Jahre' },    // follows $consent.setLocale()
}]

A locale that is not listed gets the fallbackLocale entry. A category description left out falls back to the categories.<key>.description text.

Each cookie's descriptionKey is a dotted path resolved against the active locale's texts:

// nuxt.config.ts
cookies: [{ id: '_ga', descriptionKey: 'cookies.analytics.ga.description', /* … */ }]

// texts.en
cookies: { analytics: { ga: { description: 'Used by Google Analytics…' } } }

Need a Landing Page?

Modern landing pages with optional modules (blog, docs, forms, i18n). Let's discuss your project.

Build Your MVP

Full-stack SaaS development. Expert in database design, multi-tenancy, and scalable architecture.

Deployment Help

Dockerize your backend, set up CI/CD pipelines, deploy to Cloudflare or Hetzner. Early-stage setup.

Suggest a SaaS Tool

Missing a calculator or tool? Suggest what you'd like to see on our site.