Skip to content

Commit

Permalink
Feat: Rename default language settings to defaultLang to make it more…
Browse files Browse the repository at this point in the history
… understandable #CCM-26
  • Loading branch information
OndraM committed Nov 1, 2021
1 parent 4bc165d commit 6635813
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Optional config parameters could be provided on plugin initialization in the con
```js
initLmcCookieConsentManager(
{
'currentLang': 'cs',
'defaultLang': 'cs',
'onAcceptAll': (cookie, cookieConsent) => {
// custom code
},
Expand All @@ -135,7 +135,8 @@ initLmcCookieConsentManager(
| Option | Type | Default value | Description |
|---------------|----------|--------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|
| `currentLang` | string | 'cs' | Default language. One of `cs`, `en`, `sk`, `pl`. This language will be used when autodetect is disabled or when it fails. |
| `defaultLang` | string | 'cs' | Default language. One of `cs`, `en`, `sk`, `pl`. This language will be used when autodetect is disabled or when it fails. |
| `autodetectLang`| string | true | Autodetect language from the browser. If autodetect fails or detects not supported language, fallback to `defaultLang`.<br>When disabled, force language to `defaultLang`. |
| `themeCss` | string | '' | Specify path to the .css file |
| `config` | Object | {} | Override default config of the underlying library. For all parameters see [original library](https://github.com/orestbida/cookieconsent#all-available-options). |
| `on*` callbacks| function | (cookie, cookieConsent) => {} | See below for configurable callbacks. |
Expand Down
2 changes: 1 addition & 1 deletion examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h1>LMC Cookie Consent Manager Demo</h1>
window.addEventListener('load', function () {
initLmcCookieConsentManager(
{
'currentLang': 'cs',
'defaultLang': 'cs',
'onAcceptAll': (cookie, cookieConsent) => {
console.log(cookie);

Expand Down
9 changes: 4 additions & 5 deletions src/LmcCookieConsentManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { config as configPl } from './languages/pl';
import { config as configSk } from './languages/sk';

const defaultOptions = {
currentLang: 'cs',
defaultLang: 'cs',
themeCss: '',
onFirstAccept: (cookie, cookieConsent) => {},
onFirstAcceptOnlyNecessary: (cookie, cookieConsent) => {},
Expand All @@ -19,7 +19,7 @@ const defaultOptions = {

/**
* @param {Object} [args] - Options for cookie consent manager
* @param {string} [args.currentLang] - Specify one of the languages you have defined
* @param {string} [args.defaultLang] - Default language. Must be one of predefined languages.
* @param {string} [args.themeCss] - Specify file to the .css file
* @param {function} [args.onFirstAccept] - Callback to be executed right after any consent is just accepted
* @param {function} [args.onFirstAcceptOnlyNecessary] - Callback to be executed right after only necessary cookies are accepted
Expand All @@ -33,7 +33,7 @@ const defaultOptions = {
const LmcCookieConsentManager = (args) => {
const options = { ...defaultOptions, ...args };
const {
currentLang,
defaultLang,
themeCss,
onFirstAccept,
onFirstAcceptOnlyNecessary,
Expand All @@ -44,12 +44,11 @@ const LmcCookieConsentManager = (args) => {
config,
} = options;
const cookieName = 'lmc_ccm';

const cookieConsent = window.initCookieConsent();
const isFirstTimeAccept = !cookieConsent.validCookie(cookieName);

cookieConsent.run({
current_lang: currentLang,
current_lang: defaultLang,
auto_language: true,
theme_css: themeCss,
cookie_name: cookieName,
Expand Down

0 comments on commit 6635813

Please sign in to comment.