Hi @zetpap,
In Cookiebot Language chose “Use WordPress Language”. This should pick up the WPML language. Also add your languages in the Manager as described here.
If you are using a cache plugin, remember to update the cache.
Does that work?
Thread Starter
zetpap
(@zetpap)
Hi again.
In my custom cms site (barbastathis.com), I have set the default language to Greek. I have no option to clear the cache. No luck there, I always get the message in English.
In my wordpress site (xrisizimi.gr) the message is shown in Greek but when the language changes it stays Greek.
Thank you again for your help!
@zetpap
Let’s solve one problem at a time.
In you WordPress site, chose “Use WordPress Language” under the Cookiebot Language option. See this screenshot: http://prntscr.com/lk6091
Also, add both Greek and English in the Manager, described here.
Does it work?
Thread Starter
zetpap
(@zetpap)
Ok, one problem solved!
Let’s go to the second one.
Thank you very much btw π
@zetpap
The reason barbastathis.com shows English, is because your browser language is set to English. If you browser language was set to Greek, it would shown in Greek. This is the auto-detect feature of Cookiebot.
You can check your personal browser language with this code:
<script type="text/javascript">
var userLang = navigator.language || navigator.userLanguage;
alert ("The language is: " + userLang);
</script>
If you want to enforce a specific language, you can use the data-culture attribute.
Can you insert below code on your Greek website:
<script id="Cookiebot" src="https://consent.cookiebot.com/uc.js" data-culture="EL" data-cbid="e89a4ff3-3f95-43d3-8505-ef94dd059c84" type="text/javascript" async></script>
and on your English website:
<script id="Cookiebot" src="https://consent.cookiebot.com/uc.js" data-culture="EN" data-cbid="e89a4ff3-3f95-43d3-8505-ef94dd059c84" type="text/javascript" async></script>
?
Thread Starter
zetpap
(@zetpap)
Indeed my system language is in English.
Is there a way to set it as in WordPress, to follow the site’s language.
My site doesn’t seem to have a second header.php for the english version.
One last question: Is there a script like [cookie_declaration lang=””] for me to use in my custom cms site so I can have my cookies updated?
Thank you again for all your help!!
@zetpap
Do you have a way of getting the current culture of the page? English or Greek.
If so, you could use something like;
<?php $curLang = substr(get_locale()), 0, 2); ?>
<script id="Cookiebot" data-culture="<?php echo $curLang?>" src="https://consent.cookiebot.com/uc.js" data-cbid="e89a4ff3-3f95-43d3-8505-ef94dd059c84" type="text/javascript" async></script>
where substr(get_locale()), 0, 2); would get either EN or EL.
One last question: Is there a script like [cookie_declaration lang=ββ] for me to use in my custom cms site so I can have my cookies updated?
You can use data-culture with cd.js as well;
<script id="CookieDeclaration" src="https://consent.cookiebot.com/e89a4ff3-3f95-43d3-8505-ef94dd059c84/cd.js" data-culture="EN" type="text/javascript" async></script>
Again, if you want it dynamically, you should get the current language through code. How to achieve that depends on which programming language you are using. If there is no value for it, you can extract it from the URL.
This is a javascript example just to demonstrate the approach:
var currentUserPagePathname = location.pathname.toLowerCase();
var currentUserPageCulture = "en"; //default to English
if (currentUserPagePathname.indexOf("/fr")==0)
{
currentUserPageCulture = "fr";
}
else if (currentUserPagePathname.indexOf("/es")==0)
{
currentUserPageCulture = "es";
}