cookiepal.oss
Banner

Translations

Localize banner copy, category labels, and cookie descriptions — with optional AI-assisted translation.

The banner is fully localizable. Every piece of user-facing text — banner copy, button labels, category names, per-cookie descriptions — can be translated per locale, either by hand or with AI assistance from the dashboard.

Bundled locales

@cookiepal-oss/consent ships with translations for 25 locales, covering all EU official languages and a handful of common ones. They're exported for reference:

import { DEFAULT_TRANSLATIONS, DEFAULT_TRANSLATION_LOCALES } from '@cookiepal-oss/consent';

DEFAULT_TRANSLATION_LOCALES;
// => ['bg', 'cs', 'da', 'de', 'el', 'en', 'es', 'et', 'fi', 'fr', 'ga', 'hr',
//     'hu', 'it', 'lb', 'lt', 'lv', 'mt', 'nl', 'pl', ...]

The bundled translations cover banner strings (banner.title, banner.description, button labels, "Powered by…", etc.). The banner falls back to these keys automatically when a custom i18n.locales[locale] entry is missing a string.

The i18n config shape

Override or extend the defaults via CookiepalConfig.i18n:

const config: CookiepalConfig = {
  categories: [/* ... */],
  i18n: {
    defaultLocale: 'en',
    locales: {
      en: {
        'banner.title': 'Cookie settings',
        'banner.description': 'We use cookies to…',
        'button.accept': 'Accept all',
        'button.reject': 'Reject all',
        'button.customise': 'Customize',
        'button.save': 'Save preferences',
      },
      fr: {
        'banner.title': 'Paramètres des cookies',
        // any keys you omit fall back to bundled French or, finally, English
      },
    },
  },
};

The runtime picks the active locale from the browser's navigator.language when the banner loads, falling back to defaultLocale if the best-matching locale isn't in i18n.locales.

CategoryConfig and CookieConfig both accept a locale map. It sits alongside the default English text and lets the banner show translated category names and cookie descriptions in the preferences modal:

{
  slug: 'analytics',
  locale: {
    fr: { title: 'Analytique', description: 'Mesure d\'audience…' },
    de: { title: 'Analyse', description: 'Messung der Besucheraktivität…' },
  },
}

Translating from the dashboard

Open cookiepal dashboard, go to the Languages tab. From there you can:

  • Pick a default locale.
  • Add or remove active locales.
  • Hand-edit banner strings, category strings, and per-cookie strings for each active locale.
  • Click Translate to auto-fill the active locale from your default using an AI provider.

Everything writes back to the local SQLite file; the next cookiepal build bakes the updated i18n map into the generated bundle.js.

AI translation

The dashboard's Translate button calls a local API route that asks an AI model to translate your default-locale strings into the active locale. It's opt-in and key-scoped — no translation happens until you've added an API key in Settings.

Supported providers:

ProviderDefault modelConfigure
OpenAIgpt-4o-miniPaste an sk-… key into Settings → AI
Anthropicclaude-haiku-4-5-20251001Paste an Anthropic API key into Settings → AI

Notes:

  • Keys are encrypted with AES-256-GCM before landing in SQLite. The encryption key is derived per-DB-file, so losing the DB means losing the stored API key.
  • The prompt is shaped specifically for cookie-consent copy — it preserves placeholders, keeps a formal tone, and asks for concise output.
  • Only the strings you're translating are sent to the provider. Nothing about your site, visitors, or categories is included.
  • If the provider returns malformed JSON, the dashboard falls back to leaving the field untranslated rather than inserting a guess.

Programmatic translation

If you're building your own tooling (CI job, CMS plugin, etc.), translate strings however you like and inject them into CookiepalConfig.i18n.locales before calling createConsentManager(config) — see the Programmatic API.

On this page