orestbida / cookieconsent

:cookie: Simple cross-browser cookie-consent plugin written in vanilla js
https://playground.cookieconsent.orestbida.com/
MIT License
4.08k stars 416 forks source link

[Bug]: modal is not displayed when translation for default language is not present #715

Closed veyu closed 3 months ago

veyu commented 3 months ago

Expected Behavior

I would expect some kind of error message in console when translation cannot be found.

Current Behavior

Currently there is no message in console and modal is not displayed. I spent a lot of time debugging until I realized that I did not changed identifier of translation to match default language setting.

Steps to reproduce

  1. Use config downloaded from playground.
  2. Change language default to something else:
    language: {
    default: "de",
    autoDetect: "browser",
    translations: {
      en: { ... }
    }
    },
  3. Visit page/reload.

Proposed fix or additional info.

What was confusing for me was the fact that on my personal computer it did worked correctly (MacOs Sonoma 14.2.1; Firefox 128.0.3 (64-bit) ) and I was seeing changes which I introduced. But when someone else tried opening this page, browser would not show modal. Other people tried it from many different locations on Windows with different browsers (Chrome, Firefox, Opera). I used some old laptop with Windows and was able to confirm problem reported by others. I was not able to find out why it was working on my machine (tried incognito mode, clearing cache, different browsers - still worked for me). Finally after using old laptop as test device I pinpointed above issue to be the cause.

Version

3.0.1

On which browser do you see the issue?

Firefox, Chrome, Other

orestbida commented 3 months ago

Yea, we should throw an error.