Skip to content

Commit

Permalink
Feat: Make part of settings modal text overridable
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraM committed Jun 13, 2023
1 parent 34e2340 commit 7eccc48
Show file tree
Hide file tree
Showing 13 changed files with 113 additions and 96 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ initLmcCookieConsentManager( // when loaded as a module, these options are passe
| `displayMode` | DisplayMode (string) | `DisplayMode.FORCE` (`force`) | `force` (default) to show consent in a centered modal box and to block page until user action. `soft` to show consent banner on the bottom of the page and do not block the page before user action. |
| `secondaryButtonMode` | SecondaryButtonMode (string) | `SecondaryButtonMode. ACCEPT_NECESSARY` (`acceptNecessary`) | Which button should be shown next to "Accept all". `acceptNecessary` (default) or `showSettings` (this option also hides link to show settings in consent text). |
| `on*` callbacks | function | `(cookieConsent) => {}` | See below for configurable callbacks. |
| `translationOverrides` | Record<string, TranslationOverride> | `{}` | Override default translation for specified languages. `consentTitle` and/or `descriptionIntro` could be overridden.<br>[See example][examples-configuration] |
| `translationOverrides` | Record<string, TranslationOverride> | `{}` | Override default translation for specified languages. `consentTitle`, `descriptionIntro` and `settingsModalMoreInfo` could be overridden.<br>[See example][examples-configuration] |
### Supported languages
Expand Down
3 changes: 3 additions & 0 deletions examples/configuration.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ <h2 class="mt-md-3 mb-3">Use cookieConsent instance</h2>
sk: {
consentTitle: 'Prispôsobený titulok',
descriptionIntro: 'Prispôsobený úvodný text.',
settingsModalMoreInfo: `Viz <a href="https://www.lmc.eu/sk/cookies" target="_blank">vlastný odkaz</a> a tiež
<a href="https://www.lmc.eu/sk/zasady-ochrany-sukromia" target="_blank">druhý</a>
a <a href="https://www.lmc.eu/" target="_blank">tretí</a> vlastný odkaz</a>.`,
},
}
}
Expand Down
114 changes: 56 additions & 58 deletions src/languages/__tests__/__snapshots__/langConfig.test.ts.snap

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions src/languages/cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ export const config = (
save_settings_btn: 'Uložit nastavení',
blocks: [
{
description: `Abyste z našich stránek získali maximum, je nejlepší povolit všechny typy Cookies.
Další informace o tom, co jsou Cookies a jak s nimi pracujeme, najdete na stránkách
<a href="https://www.lmc.eu/cs/cookies/" target="_blank">Používání Cookies</a>
a <a href="https://www.lmc.eu/cs/zasady-ochrany-soukromi" target="_blank">Zásady ochrany soukromí</a>.`,
description:
`Abyste z našich stránek získali maximum, je nejlepší povolit všechny typy Cookies.\n` +
(lang.settingsModalMoreInfo ??
`Další informace o tom, co jsou Cookies a jak s nimi pracujeme, najdete na stránkách
<a href="https://www.lmc.eu/cs/cookies/" target="_blank">Používání Cookies</a>
a <a href="https://www.lmc.eu/cs/zasady-ochrany-soukromi" target="_blank">Zásady ochrany soukromí</a>.`),
},
{
title: 'Technicky nezbytné Cookies',
Expand Down
12 changes: 7 additions & 5 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ export const config = (
save_settings_btn: 'Einstellungen speichern',
blocks: [
{
description: `Um unsere Website optimal nutzen zu können, sollten Sie alle Arten von Cookies aktivieren.
Weitere Informationen darüber, was Cookies sind und wie wir mit ihnen arbeiten,
finden Sie in unseren Richtlinien
zur <a href="https://www.lmc.eu/en/cookies/" target="_blank">Verwendung von Cookies</a>
und zum <a href="https://www.lmc.eu/en/privacy-policy/" target="_blank">Datenschutz</a>.`,
description:
`Um unsere Website optimal nutzen zu können, sollten Sie alle Arten von Cookies aktivieren.\n` +
(lang.settingsModalMoreInfo ??
`Weitere Informationen darüber, was Cookies sind und wie wir mit ihnen arbeiten,
finden Sie in unseren Richtlinien
zur <a href="https://www.lmc.eu/en/cookies/" target="_blank">Verwendung von Cookies</a>
und zum <a href="https://www.lmc.eu/en/privacy-policy/" target="_blank">Datenschutz</a>.`),
},
{
title: 'Technisch notwendige Cookies',
Expand Down
10 changes: 6 additions & 4 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ export const config = (
save_settings_btn: 'Save settings',
blocks: [
{
description: `If you want to get the most out of our website it is best to allow all types of cookies.
You can find more information about what cookies are and how we work with them via the links
to <a href="https://www.lmc.eu/en/cookies/" target="_blank">The use of cookies</a>
and <a href="https://www.lmc.eu/en/privacy-policy/" target="_blank">Privacy policy</a>.`,
description:
`If you want to get the most out of our website it is best to allow all types of cookies.\n` +
(lang.settingsModalMoreInfo ??
`You can find more information about what cookies are and how we work with them via the links
to <a href="https://www.lmc.eu/en/cookies/" target="_blank">The use of cookies</a>
and <a href="https://www.lmc.eu/en/privacy-policy/" target="_blank">Privacy policy</a>.`),
},
{
title: 'Technically necessary cookies',
Expand Down
10 changes: 6 additions & 4 deletions src/languages/hu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ export const config = (
save_settings_btn: 'Beállítások mentése',
blocks: [
{
description: `Ahhoz, hogy a maximumot hozhassa ki webhelyünkből, a legjobb, ha engedélyezi az összes
cookie típust. További információkat arról, hogy mik azok a cookie-k és hogyan dolgozunk velük
a <a href="https://www.lmc.eu/en/cookies/" target="_blank">Cookie-k használata</a>
és az <a href="https://www.lmc.eu/en/privacy-policy/" target="_blank">Adatvédelmi szabályzat honlapjain talál</a>.`,
description:
`Ahhoz, hogy a maximumot hozhassa ki webhelyünkből, a legjobb, ha engedélyezi az összes cookie típust.\n` +
(lang.settingsModalMoreInfo ??
`További információkat arról, hogy mik azok a cookie-k és hogyan dolgozunk velük
a <a href="https://www.lmc.eu/en/cookies/" target="_blank">Cookie-k használata</a>
és az <a href="https://www.lmc.eu/en/privacy-policy/" target="_blank">Adatvédelmi szabályzat honlapjain talál</a>.`),
},
{
title: 'Technikailag szükséges cookie-k',
Expand Down
11 changes: 6 additions & 5 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ export const config = (
save_settings_btn: 'Zapisz ustawienia',
blocks: [
{
description: `Aby w pełni wykorzystać możliwości naszej strony, najlepiej jest zezwolić na wszystkie
rodzaje plików cookies. Aby uzyskać więcej informacji na temat tego, czym są pliki cookies
i jak z nimi pracujemy, odwiedź na naszej stronie
<a href="https://www.lmc.eu/pl/cookies" target="_blank">Korzystanie z plików cookies</a>
i <a href="https://www.lmc.eu/pl/polityka-prywatnosci" target="_blank">Politykę prywatności</a>.`,
description:
`Aby w pełni wykorzystać możliwości naszej strony, najlepiej jest zezwolić na wszystkie rodzaje plików cookies.\n` +
(lang.settingsModalMoreInfo ??
`Aby uzyskać więcej informacji na temat tego, czym są pliki cookies i jak z nimi pracujemy, odwiedź na naszej stronie
<a href="https://www.lmc.eu/pl/cookies" target="_blank">Korzystanie z plików cookies</a>
i <a href="https://www.lmc.eu/pl/polityka-prywatnosci" target="_blank">Politykę prywatności</a>.`),
},
{
title: 'Technicznie niezbędne pliki cookies',
Expand Down
12 changes: 7 additions & 5 deletions src/languages/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ export const config = (
save_settings_btn: 'Сохранить настройки',
blocks: [
{
description: `Чтобы Вы могли в максимальной мере и без проблем пользоваться нашим сайтом, мы рекомендуем
разрешить просматривать и сохранять все типы файлов cookie.
Вы можете найти дополнительную информацию о том, что такое файлы cookies, и как мы с ними работаем,
на страницах <a href="https://www.lmc.eu/en/cookies/" target="_blank">Использование файлов cookie</a>
и <a href="https://www.lmc.eu/en/privacy-policy/" target="_blank">Политика конфиденциальности персональных данных</a>.`,
description:
`Чтобы Вы могли в максимальной мере и без проблем пользоваться нашим сайтом, мы рекомендуем
разрешить просматривать и сохранять все типы файлов cookie.\n` +
(lang.settingsModalMoreInfo ??
`Вы можете найти дополнительную информацию о том, что такое файлы cookies, и как мы с ними работаем,
на страницах <a href="https://www.lmc.eu/en/cookies/" target="_blank">Использование файлов cookie</a>
и <a href="https://www.lmc.eu/en/privacy-policy/" target="_blank">Политика конфиденциальности персональных данных</a>.`),
},
{
title: 'Технически необходимые файлы cookie',
Expand Down
10 changes: 6 additions & 4 deletions src/languages/sk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ export const config = (
save_settings_btn: 'Uložiť nastavenia',
blocks: [
{
description: `Aby ste z našich stránok získali maximum, je najlepšie povoliť všetky typy cookies.
Ďalšie informácie o tom, čo sú cookies a ako s nimi pracujeme, nájdete na stránkach
<a href="https://www.lmc.eu/sk/cookies" target="_blank">Používania cookies</a>
a v <a href="https://www.lmc.eu/sk/zasady-ochrany-sukromia" target="_blank">Zásadách ochrany súkromia</a>.`,
description:
`Aby ste z našich stránok získali maximum, je najlepšie povoliť všetky typy cookies.\n` +
(lang.settingsModalMoreInfo ??
`Ďalšie informácie o tom, čo sú cookies a ako s nimi pracujeme, nájdete na stránkach
<a href="https://www.lmc.eu/sk/cookies" target="_blank">Používania cookies</a>
a v <a href="https://www.lmc.eu/sk/zasady-ochrany-sukromia" target="_blank">Zásadách ochrany súkromia</a>.`),
},
{
title: 'Technicky nevyhnutné cookies',
Expand Down
10 changes: 6 additions & 4 deletions src/languages/uk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ export const config = (
save_settings_btn: 'Зберегти налаштування',
blocks: [
{
description: `Щоб отримати максимальну віддачу від нашого сайту, найкраще дозволити всі типи файлів Cookies.
Додаткову інформацію про те, що таке файли Cookies і як ми з ними працюємо, можна отримати на сторінках
<a href="https://www.lmc.eu/en/cookies/" target="_blank">Використання Cookies</a>
і <a href="https://www.lmc.eu/en/privacy-policy/" target="_blank">Політика конфіденційності</a>.`,
description:
`Щоб отримати максимальну віддачу від нашого сайту, найкраще дозволити всі типи файлів Cookies.\n` +
(lang.settingsModalMoreInfo ??
`Додаткову інформацію про те, що таке файли Cookies і як ми з ними працюємо, можна отримати на сторінках
<a href="https://www.lmc.eu/en/cookies/" target="_blank">Використання Cookies</a>
і <a href="https://www.lmc.eu/en/privacy-policy/" target="_blank">Політика конфіденційності</a>.`),
},
{
title: 'Технічно необхідні файли Cookies',
Expand Down
4 changes: 2 additions & 2 deletions src/types/CookieConsentManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { CookieConsentCategory, DisplayMode } from '../constants';
import { CookieConsentCategory, DisplayMode, SecondaryButtonMode } from '../constants';
import { VanillaCookieConsent } from './vanilla-cookieconsent';
import { SecondaryButtonMode } from '../constants/SecondaryButtonMode';

export type Values<T> = T[keyof T];

Expand All @@ -24,6 +23,7 @@ export type OnChangeCallback = (
export type TranslationOverride = {
consentTitle?: string;
descriptionIntro?: string;
settingsModalMoreInfo?: string;
};

export type CookieConsentManagerOptions = {
Expand Down
1 change: 1 addition & 0 deletions src/types/Messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export interface ExtraMessages {
companyNames: string[];
consentTitle?: string;
descriptionIntro?: string;
settingsModalMoreInfo?: string;
}

0 comments on commit 7eccc48

Please sign in to comment.