Language switch issue #150
-
Hi! I'm using a button that changes the value in Example in vanilla js below: So far so good. The language changes and everything is translating correctly in the page except cookie consent. In my static pages I use I'm using useContext for the React pages current language globally in react pages. Do we have a bug here or does this script only work with hard refresh to another language or am I doing it all wrong? Here is my React code: useEffect(() => { |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Updated description and tested with vanilla js and with react. |
Beta Was this translation helpful? Give feedback.
-
Hi @AhaDigital , Do we have a bug here or does this script only work with hard refresh to another language or am I doing it all wrong? Yes, the plugin is initialized only once. Since it doesn't have any active listeners, and doesn't use any react state (the plugin is not a react component) it can't update automatically the content of the modals. Currently the only way to change the language — without reloading the page — would be to remove the root With that being said, I will consider adding a |
Beta Was this translation helpful? Give feedback.
Hi @AhaDigital ,
Do we have a bug here or does this script only work with hard refresh to another language or am I doing it all wrong?
I also wonder if there is a way to re-initialize window.initCookieConsent(); if there is no way to update language dynamically?
Yes, the plugin is initialized only once. Since it doesn't have any active listeners, and doesn't use any react state (the plugin is not a react component) it can't update automatically the content of the modals.
Currently the only way to change the language — without reloading the page — would be to remove the root
HTMLDivElement
from the DOM:<div id="cc--main">...</div>
and then call again the.run({...})
method with the new la…