eibiflo / cf_cookiemanager

Simple Typo3 Cookie Manager
GNU General Public License v2.0
10 stars 4 forks source link

user_config.languages[lang] is undefined #11

Closed jacques2017 closed 8 months ago

jacques2017 commented 9 months ago

Hi, I get an js-error:

Uncaught TypeError: user_config.languages[lang] is undefined _createConsentModal http://DOMAIN.TLD/_assets/0495dc5aa206d96a6c2bfbe3dbb13f6d/JavaScript/thirdparty/consent.js?1696231373:442 _createCookieConsentHTML http://DOMAIN.TLD/_assets/0495dc5aa206d96a6c2bfbe3dbb13f6d/JavaScript/thirdparty/consent.js?1696231373:1096 run http://DOMAIN.TLD/_assets/0495dc5aa206d96a6c2bfbe3dbb13f6d/JavaScript/thirdparty/consent.js?1696231373:1694

http://DOMAIN.TLD/#:2286 EventListener.handleEvent* http://DOMAIN.TLD/#:2196

I use the latest Version in Composer-Mode in TYPO3 V12 The site-configuration is "DE" . I have the following debug-log:

CookieConsent [CONFIG]: received_config_settings
Object { languages: {…}, onAccept: onAccept(), onChange: onChange(cookie, changed_preferences) } consent.js:192:12 CookieConsent [LANG]: auto_language strategy is 'null' consent.js:256:21 CookieConsent _config.current_lang en consent.js:259:12

Why is "_config.current_lang" = "en" and not "de"? In the backendconfiguration of cf_cookiemanager the language is set to "de"

Please help.

Jacques ​

eibiflo commented 9 months ago

Hei @jacques2017, Feel free to join the T3 Slack channel to discuss this in detail, or please send me a PM. https://typo3.slack.com/archives/C04NB2ZP30U

This is not familiar to me, so I would need to take a closer look on your js file.

Thanks for your Issue!

jacques2017 commented 9 months ago

Hi eibiflo, thanks for your answer.

In file \cf-cookiemanager\Resources\Public\JavaScript\thirdparty\consent.js at line 23 I change 'current_lang': 'en', to 'current_lang': 0,

Now it works for me. Is it possible to set the language for the cookiemanager-configuration in the TYPO3-backend? Now I changed the js-file on the server, but it will be overwritten at the next version.

My js-file now looks like this:

`/*!

eibiflo commented 9 months ago

Hei @jacques2017

The language configuration actually comes from your site config.yaml; here, the sys_language_uid is used. Could it be that you had an old version before, and this has been occurring since an update?

In fact, the ID should be set here: https://github.com/eibiflo/cf_cookiemanager/blob/main/Classes/Domain/Repository/CookieFrontendRepository.php#L460

This actually comes from: https://github.com/eibiflo/cf_cookiemanager/blob/main/Classes/Controller/CookieFrontendController.php#L57

This changed in version 1.1.x; maybe you had an old version, or can you rule that out?

It looks like the _setConfig in js is not called, so it use the Default settings.

I would suggest sending me a quick Slack message with your real host name, and we can discuss this in a private chat. If we can find the error, I can also publish a patch right away. I'm genuinely interested in where the issue might be; the extension runs smoothly in my installations.

eibiflo commented 9 months ago

@jacques2017 You can try the release: https://github.com/eibiflo/cf_cookiemanager/releases/tag/v1.3.4 by a simple composer update.

I changed the default language to 0. However, I'm still interested in why this doesn't work for you by default.

eibiflo commented 8 months ago

@jacques2017 Has your issue been resolved? If so, I will close the issue.