-
-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: autoDetect with value 'document' is not working #607
Comments
This works just fine on my end, can you post your configuration? |
Sure, here it is below. Here the value is set to import 'https://cdn.jsdelivr.net/gh/orestbida/cookieconsent@v3.0.0-rc.17/dist/cookieconsent.umd.js';
CookieConsent.run({
root: '#wrapper',
cookie: {
name: 'ai_gdpr',
domain: ( window.DOMAIN_NAME || window.location.hostname ),
path: '/',
expiresAfterDays: function(acceptType)
{
return( acceptType === 'all' ? 400 : 182 );
},
sameSite: 'Lax',
},
onFirstConsent: function(cookie)
{
// todo
},
onConsent: function(cookie)
{
},
onChange: function(cookie, changedCategories, changedPreferences)
{
// todo
},
onModalShow: function(modalName)
{
},
onModalHide: function(modalName)
{
// todo
},
onModalReady: function(modalName, modal)
{
// todo
},
guiOptions: {
consentModal: {
layout: "cloud inline",
position: "bottom right",
equalWeightButtons: true,
flipButtons: false
},
preferencesModal: {
layout: "box",
position: "right",
equalWeightButtons: true,
flipButtons: false
}
},
categories: {
necessary: {
readOnly: true
},
functionality: {
enabled: true,
readOnly: false,
},
analytics: {
enabled: true,
readOnly: false,
autoClear: {
cookies: [
{
name: /^(_ga)/ // regex
// path: string
// domain: string
},
{
name: '_gid' // string
}
]
},
services: {
ga: {
label: 'Google Analytics',
onAccept: function()
{
// enable ga
},
onReject: function()
{
// disable ga
},
cookies: [
{
name: /^(_ga|_gid)/
}
]
},
},
},
marketing: {
enabled: true,
readOnly: false,
}
},
language: {
default: "en",
autoDetect: "browser",
translations: {
"en-GB": "/public/cookieconsent-en_GB.json",
"fr-FR": "/public/cookieconsent-fr_FR.json",
"ja-JP": "/public/cookieconsent-ja_JP.json",
}
}
}); |
Ok, I could pinpoint the root cause, which was a comma at the end of a line as last property of an hash in the JSON file. In the JavaScript configuration file, it is permissible, but not under JSON. You can close it. Although I think it would be helpful if your software could log a warning or an error in the console if upon parsing the JSON data an error is caught. |
You're right, it would be better to throw a visible error in the console since I also have encountered this issue. |
Expected Behavior
I would expect cookieconsent to take the language value from
<html lang="ja-JP">
for example, as advertised, when the value ofautoDetect
is set todocument
Current Behavior
I am using Firefox version 120.0.1 on a MacOS Ventura on a MacBook Pro M2.
When
autoDetect
is set todocument
, no cookies notification is displayed.If I change the settings to
browser
, then the cookies notification is displayed, but in the browser language, not the user preferred language on the website.Steps to reproduce
autoDetect
is set todocument
Proposed fix or additional info.
No response
Version
v3.0.0-rc.17
On which browser do you see the issue?
Firefox
The text was updated successfully, but these errors were encountered: