@cookieyes/translations
v0.5.0
Published
Curated translation catalog for the CookieYes consent SDK. Import only the locales you need — each is its own sub-path so unused languages don't bundle.
Readme
This package only provides locale strings — for which API to use to read consent status, see the shared decision tree.
Key features
- Five locales — English (
en), Spanish (es), French (fr), German (de), Italian (it). - Tree-shakeable — per-locale sub-path exports; import one language, ship only that one.
- Complete
TranslationMap— every string the banner, preferences dialog, and opt-out use. - Drop-in — pass straight to
initCookieYes({ i18n: { messages } }); no adapter needed.
Prerequisites
- Node.js ≥ 20
- A CookieYes SDK package to consume the strings —
@cookieyes/core,@cookieyes/react, or@cookieyes/nextjs.
Quick start
1. Install
npm install @cookieyes/translations
pnpm add @cookieyes/translations
yarn add @cookieyes/translations
bun add @cookieyes/translations2. Import the locales you need (each is a named export):
import { en } from "@cookieyes/translations/en";
import { fr } from "@cookieyes/translations/fr";3. Pass them to the SDK via initCookieYes:
import { initCookieYes } from "@cookieyes/react"; // or @cookieyes/core / @cookieyes/nextjs
initCookieYes({
mode: "cookie-only", // no backend
i18n: {
messages: { en, fr },
locale: "fr", // active locale; omit to auto-detect from the browser
},
});4. Done. The banner and dialogs now render in the selected locale.
Available locales
| Sub-path | Language |
|----------|----------|
| @cookieyes/translations/en | English |
| @cookieyes/translations/es | Spanish |
| @cookieyes/translations/fr | French |
| @cookieyes/translations/de | German |
| @cookieyes/translations/it | Italian |
The package root (@cookieyes/translations) re-exports shared types only — locale tables
are not re-exported there, so importing one language never pulls in the others.
Troubleshooting
Cannot find module '@cookieyes/translations' (or a locale sub-path).
Import from the sub-path, not the root: @cookieyes/translations/fr, not
@cookieyes/translations. The root exports types only. Available sub-paths are en, es, fr,
de, it — any other path won't resolve.
Text doesn't change after I pass a locale.
Make sure the imported locale is actually placed in i18n.messages and selected via
i18n.locale (e.g. { messages: { en, fr }, locale: "fr" }). If you only pass messages
without locale, the SDK auto-detects from the browser and may not pick the one you expect. The
runtime is a singleton — changing the config after the first initCookieYes(...) call has no
effect until the runtime is reset.
Still stuck? Open an issue.
Community & support
- Open an issue — bug reports and feature requests.
- Email — [email protected].
- Full documentation.
(A community chat channel is on the roadmap.)
Contributing
Contributions are welcome — new locales especially. Read our Contributing Guidelines and Code of Conduct, then open a pull request.
Security
Found a vulnerability? Do not open a public issue — follow our Security Policy and use GitHub's private vulnerability reporting.
License
MIT — see LICENSE.
