running a a site in 3 different languages i am wondering how to accomplish so this module does adapt to the chosen language?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

budda’s picture

Status: Active » Postponed (maintainer needs more info)

Interesting point. Didn't consider that with user configurable text input. Is there a common pattern to supporting this requirement in other modules that you may know of?

The text message is stored in a Drupal variable called 'cookiecontrol_text'.

Short term, you could set the text string in your sites settings.php $conf[] variable based on the detected language. However that is a bit of a hack.

bavarian’s picture

Well for a site in one language (English) things are just fine ...

But if site is in one other language (German) it would not look nice to have the text in the pop-up all in English.

And if site is offering several languages, and English is one of those languages it might be ok with English but to me it seems just natural that the text in the pop-ut that this module creates is in the same language as the rest of the site ....

budda’s picture

Version: 7.x-1.2 » 7.x-1.x-dev

I understand that the need for other language on the same site.

Please, if you are aware, point me at some other modules which handle the same sort of configuration so i can see what a suitable solution might be.

Thanks.

bavarian’s picture

I am able to extract and re-import PO-translation files for this module.
Doing this I am able to translate parts of this module like "I am happy with this", "Browser Settings", "show the cookie icon" and "By using our site you accept the terms" .....

What I can't find a solution for is to translate "This site uses cookies to store information on your computer. Some of these cookies are essential to make our site work and others help us to improve by giving us some insight into how the site is being used." for all languages I have.

I guess it takes more text boxes for language1, language2, language3 on a sajt in admin/config/people/cookiecontrol to provide translations for "This site uses cookies to store information on your computer. Some of these cookies are essential to make our site work and others help us to improve by giving us some insight into how the site is being used."

budda’s picture

The default text is not held in a t() string so it wont be visible to the translation system. I can move it in to a t() wrapper but my assumption was that sites would write their own text on the settings page, in their own language.

But inputing the text on the settings page doesn't help with the multi lingual sites. Having multiple text boxes on the settings page wont be practical.

At least making the default text translatable will be practical for you right now though I assume?

bavarian’s picture

I guess that making the default text translatable would be practical for me .. yes !!!!!!

budda’s picture

Status: Postponed (maintainer needs more info) » Fixed

Done in dev code.
Also on a side note from fixing #1532182: Country restriction some translate strings have changed.

bavarian’s picture

on http://drupal.org/project/cookiecontrol

it says the dev-version is from 5th of April ...

where to get dev-code you mentioned in posting above here?

budda’s picture

Either wait for drupal.org to re-package a new dev snapshot. I think its every 12 hours (?) or use git to clone the project, or download via http://drupalcode.org/project/cookiecontrol.git/tree/refs/heads/7.x-1.x - use the 'snapshot' link to get a tar.gz archive of the code.

bavarian’s picture

after uninstalling version 7x-1.3 and installing 7.x-1.x-dev my complete page renders like with text as follwoigng down here all over ...

switching back to 7.x-1.3 makes everything work normal again

rray(27) { ["settings"]=> array(6) { ["data"]=> array(9) { [0]=> array(1) { ["basePath"]=> string(1) "/" } [1]=> array(1) { ["pathPrefix"]=> string(0) "" } [2]=> array(1) { ["ajaxPageState"]=> array(2) { ["theme"]=> string(5) "totte" ["theme_token"]=> string(43) "4bFRj1FX1Te_z5KMuNIzsx_YI5dkM1OK3QtWyC1vbog" } } [3]=> array(1) { ["toc_filter_smooth_scroll_duration"]=> string(0) "" } [4]=> array(1) { ["extlink"]=> array(8) { ["extTarget"]=> int(0) ["extClass"]=> string(3) "ext" ["extSubdomains"]=> int(0) ["extExclude"]=> string(0) "" ["extInclude"]=> string(0) "" ["extAlert"]=> int(0) ["extAlertText"]=> string(90) "This link will take you to an external web site. We are not responsible for their content." ["mailtoClass"]=> string(6) "mailto" } } [5]=> array(1) { ["ip_geoloc_menu_callback"]=> string(26) "ip-geoloc-current-location" } [6]=> array(1) { ["viewsSlideshow"]=> array(1) { ["banner-block_1"]=> array(2) { ["methods"]=> array(7) { ["goToSlide"]=> array(4) { [0]=> string(19) "viewsSlideshowPager" [1]=> string(26) "viewsSlideshowSlideCounter" [2]=> string(19) "viewsSlideshowCycle" [3]=> string(22) "viewsSlideshowGalleria" } ["nextSlide"]=> array(4) { [0]=> string(19) "viewsSlideshowPager" [1]=> string(26) "viewsSlideshowSlideCounter" [2]=> string(19) "viewsSlideshowCycle" [3]=> string(22) "viewsSlideshowGalleria" } ["pause"]=> array(2) { [0]=> string(22) "viewsSlideshowControls" [1]=> string(19) "viewsSlideshowCycle" } ["play"]=> array(2) { [0]=> string(22) "viewsSlideshowControls" [1]=> string(19) "viewsSlideshowCycle" } ["previousSlide"]=> array(4) { [0]=> string(19) "viewsSlideshowPager" [1]=> string(26) "viewsSlideshowSlideCounter" [2]=> string(19) "viewsSlideshowCycle" [3]=> string(22) "viewsSlideshowGalleria" } ["transitionBegin"]=> array(3) { [0]=> string(19) "viewsSlideshowPager" [1]=> string(26) "viewsSlideshowSlideCounter" [2]=> string(18) "viewsSlideshowXtra" } ["transitionEnd"]=> array(0) { } } ["paused"]=> int(0) } } } [7]=> array(1) { ["viewsSlideshowCycle"]=> array(1) { ["#views_slideshow_cycle_main_banner-block_1"]=> array(28) { ["num_divs"]=> int(2) ["id_prefix"]=> string(28) "#views_slideshow_cycle_main_" ["div_prefix"]=> string(27) "#views_slideshow_cycle_div_" ["vss_id"]=> string(14) "banner-block_1" ["effect"]=> string(8) "fadeZoom" ["transition_advanced"]=> int(0) ["timeout"]=> int(5000) ["speed"]=> int(700) ["delay"]=> int(0) ["sync"]=> int(1) ["random"]=> int(0) ["pause"]=> int(1) ["pause_on_click"]=> int(0) ["action_advanced"]=> int(0) ["start_paused"]=> int(0) ["remember_slide"]=> int(0) ["remember_slide_days"]=> int(1) ["pause_when_hidden"]=> int(0) ["pause_when_hidden_type"]=> string(4) "full" ["amount_allowed_visible"]=> string(0) "" ["nowrap"]=> int(0) ["fixed_height"]=> int(0) ["items_per_slide"]=> int(1) ["wait_for_image_load"]=> int(1) ["wait_for_image_load_timeout"]=> int(3000) ["cleartype"]=> int(0) ["cleartypenobg"]=> int(0) ["advanced_options"]=> string(2) "{}" } } } [8]=> array(1) { ["googleanalytics"]=> array(4) { ["trackOutbound"]=> int(1) ["trackMailto"]=> int(1) ["trackDownload"]=> int(1) ["trackDownloadExtensions"]=> string(195) "7z|aac|arc|arj|asf|asx|avi|bin|csv|doc|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls|xml|z|zip" } } } ["type"]=> string(7) "setting" ["scope"]=> string(6) "header" ["group"]=> int(-100) ["every_page"]=> bool(true) ["weight"]=> int(0) } ["misc/drupal.js"]=> array(9) { ["data"]=> string(14) "misc/drupal.js" ["type"]=> string(4) "file" ["scope"]=> string(6) "header" ["group"]=> int(-100) ["every_page"]=> bool(true) ["weight"]=> int(-1) ["preprocess"]=> bool(true) ["cache"]=> bool(true) ["defer"]=> bool(false) } ["misc/jquery.js"]=> array(10) { ["group"]=> int(-100) ["weight"]=> float(-19.998) ["version"]=> string(5) "1.4.4" ["every_page"]=> bool(true) ["type"]=> string(4) "file" ["scope"]=> string(6) "header" ["cache"]=> bool(true) ["defer"]=> bool(false) ["preprocess"]=> bool(true) ["data"]=> string(14) "misc/jquery.js" } ["misc/jquery.once.js"]=> array(10) { ["group"]=> int(-100) ["weight"]=> float(-18.997) ["version"]=> string(3) "1.2" ["every_page"]=> bool(true) ["type"]=> string(4) "file" ["scope"]=> string(6) "header" ["cache"]=> bool(true) ["defer"]=> bool(false) ["preprocess"]=> bool(true) ["data"]=> string(19) "misc/jquery.once.js" } ["sites/all/themes/totte/scripts/script.js"]=> array(10) { ["group"]=> int(100) ["every_page"]=> bool(true) ["type"]=> string(4) "file" ["weight"]=> int(0) ["scope"]=> string(6) "header" ["cache"]=> bool(true) ["defer"]=> bool(false) ["preprocess"]=> bool(true) ["version"]=> NULL ["data"]=> string(40) "sites/all/themes/totte/scripts/script.js" } ["sites/all/modules/absolute_messages/absolute_messages.js"]=> array(10) { ["type"]=> string(4) "file" ["group"]=> int(0) ["every_page"]=> bool(false) ["weight"]=> float(0.005) ["scope"]=> string(6) "header" ["cache"]=> bool(true) ["defer"]=> bool(false) ["preprocess"]=> bool(true) ["version"]=> NULL ["data"]=> string(56) "sites/all/modules/absolute_messages/absolute_messages.js" } [0]=> array(10) { ["type"]=> string(6) "inline" ["group"]=> int(0) ["every_page"]=> bool(false) ["weight"]=> float(0.006) ["scope"]=> string(6) "header" ["cache"]=> bool(true) ["defer"]=> bool(false) ["preprocess"]=> bool(true) ["version"]=> NULL ["data"]=> string(181) "jQuery.extend(Drupal.absolute_messages, {"dismiss":{"status":0,"warning":0,"error":0},"dismiss_time":{"status":"","warning":"","error":""},"dismiss_all_count":"1","max_lines":"5"});" } ["sites/all/modules/adsense/contrib/adsense_click/adsense_click.js"]=> array(10) { ["type"]=> string(4) "file" ["group"]=> int(0) ["every_page"]=> bool(false) ["weight"]=> float(0.007) ["scope"]=> string(6) "header" ["cache"]=> bool(true) ["defer"]=> bool(false) ["preprocess"]=> bool(true) ["version"]=> NULL ["data"]=> string(64) "sites/all/modules/adsense/contrib/adsense_click/adsense_click.js" } ["sites/all/modules/cookiecontrol/js/cookieControl-3.0.1.min.js"]=> array(10) { ["every_page"]=> bool(true) ["type"]=> string(4) "file" ["group"]=> int(0) ["weight"]=> float(0.008) ["scope"]=> string(6) "header" ["cache"]=> bool(true) ["defer"]=> bool(false) ["preprocess"]=> bool(true) ["version"]=> NULL ["data"]=> string(61) "sites/all/modules/cookiecontrol/js/cookieControl-3.0.1.min.js" } ["sites/all/modules/spamspan/spamspan.js"]=> array(10) { ["every_page"]=> bool(true) ["type"]=> string(4) "file" ["group"]=> int(0) ["weight"]=> float(0.009) ["scope"]=> string(6) "header" ["cache"]=> bool(true) ["defer"]=> bool(false) ["preprocess"]=> bool(true) ["version"]=> NULL ["data"]=> string(38) "sites/all/modules/spamspan/spamspan.js" } ["sites/all/modules/toc_filter/toc_filter.js"]=> array(10) { ["type"]=> string(4) "file" ["every_page"]=> bool(true) ["group"]=> int(0) ["weight"]=> float(0.01) ["scope"]=> string(6) "header" ["cache"]=> bool(true) ["defer"]=> bool(false) ["preprocess"]=> bool(true) ["version"]=> NULL ["data"]=> string(42) "sites/all/modules/toc_filter/toc_filter.js" } ["sites/all/modules/views_slideshow/js/views_slideshow.js"]=> array(10) { ["type"]=> string(4) "file" ["group"]=> int(0) ["every_page"]=> bool(false) ["weight"]=> float(0.011) ["scope"]=> string(6) "header" ["cache"]=> bool(true) ["defer"]=> bool(false) ["preprocess"]=> bool(true) ["version"]=> NULL ["data"]=> string(55) "sites/all/modules/views_slideshow/js/views_slideshow.js" } ["sites/all/modules/views_slideshow_xtra/views_slideshow_xtra.js"]=> array(10) { ["type"]=> string(4) "file" ["group"]=> int(0) ["every_page"]=> bool(false) ["weight"]=> float(0.012) ["scope"]=> string(6) "header" ["cache"]=> bool(true) ["defer"]=> bool(false) ["preprocess"]=> bool(true) ["version"]=> NULL ["data"]=> string(62) "sites/all/modules/views_slideshow_xtra/views_slideshow_xtra.js" } ["sites/all/modules/extlink/extlink.js"]=> array(10) { ["type"]=> string(4) "file" ["group"]=> int(0) ["every_page"]=> bool(false) ["weight"]=> float(0.013) ["scope"]=> string(6) "header" ["cache"]=> bool(true) ["defer"]=> bool(false) ["preprocess"]=> bool(true) ["version"]=> NULL ["data"]=> string(36) "sites/all/modules/extlink/extlink.js" } ["http://code.google.com/apis/gears/gears_init.js"]=> array(10) { ["group"]=> int(-100) ["type"]=> string(4) "file" ["every_page"]=> bool(false) ["weight"]=> float(0.014) ["scope"]=> string(6) "header" ["cache"]=> bool(true) ["defer"]=> bool(false) ["preprocess"]=> bool(true) ["version"]=> NULL ["data"]=> string(47) "http://code.google.com/apis/gears/gears_init.js" } ["http://geo-location-javascript.googlecode.com/svn/trunk/js/geo.js"]=> array(10) { ["group"]=> int(-100) ["type"]=> string(4) "file" ["every_page"]=> bool(false) ["weight"]=> float(0.015) ["scope"]=> string(6) "header" ["cache"]=> bool(true) ["defer"]=> bool(false) ["preprocess"]=> bool(true) ["version"]=> NULL ["data"]=> string(65) "http://geo-location-javascript.googlecode.com/svn/trunk/js/geo.js" } ["http://maps.google.com/maps/api/js?sensor=true"]=> array(10) { ["group"]=> int(-100) ["type"]=> string(4) "file" ["every_page"]=> bool(false) ["weight"]=> float(0.016) ["scope"]=> string(6) "header" ["cache"]=> bool(true) ["defer"]=> bool(false) ["preprocess"]=> bool(true) ["version"]=> NULL ["data"]=> string(46) "http://maps.google.com/maps/api/js?sensor=true" } ["sites/all/modules/ip_geoloc/js/ip_geoloc_current_location.js"]=> array(10) { ["type"]=> string(4) "file" ["group"]=> int(0) ["every_page"]=> bool(false) ["weight"]=> float(0.017) ["scope"]=> string(6) "header" ["cache"]=> bool(true) ["defer"]=> bool(false) ["preprocess"]=> bool(true) ["version"]=> NULL ["data"]=> string(60) "sites/all/modules/ip_geoloc/js/ip_geoloc_current_location.js" } ["sites/all/libraries/jquery.cycle/jquery.cycle.all.min.js"]=> array(10) { ["type"]=> string(4) "file" ["group"]=> int(0) ["every_page"]=> bool(false) ["weight"]=> float(0.018) ["scope"]=> string(6) "header" ["cache"]=> bool(true) ["defer"]=> bool(false) ["preprocess"]=> bool(true) ["version"]=> NULL ["data"]=> string(56) "sites/all/libraries/jquery.cycle/jquery.cycle.all.min.js" } ["sites/all/modules/views_slideshow/contrib/views_slideshow_cycle/js/views_slideshow_cycle.js"]=> array(10) { ["type"]=> string(4) "file" ["group"]=> int(0) ["every_page"]=> bool(false) ["weight"]=> float(0.019) ["scope"]=> string(6) "header" ["cache"]=> bool(true) ["defer"]=> bool(false) ["preprocess"]=> bool(true) ["version"]=> NULL ["data"]=> string(91) "sites/all/modules/views_slideshow/contrib/views_slideshow_cycle/js/views_slideshow_cycle

budda’s picture

Fixed. Removed temp debug output from the dev snapshot release.

bavarian’s picture

default text is translatable now. BUT the module still uses the default test that resides in the database tables ... i think?

so no matter how much i translate that default string ... it will always bring upp the english default text

bavarian’s picture

at admin/config/regional/translate/translate i translated

"This site uses cookies to store information on your computer. Some of these cookies are essential to make our site work and othe"

into the desired extra languages .... but when reloading the site's start page - even after emptying caches - the cookie control popup-window does still use the English text for these 2 sentences mentioned above.

budda’s picture

Status: Fixed » Needs work

The text "This site uses cookies to store information on your computer. Some of these cookies are essential to make our site work and others help us to improve by giving us some insight into how the site is being used." is stored in a Drupal module when you save the form settings. The default text is translatable - but as soon as you save the form whatever language is in the textbox at the time becomes the default - bypassing any t() function.

You can unset the Drupal variable 'cookiecontrol_text' to restore the translated strings

bavarian’s picture

stupid question: how to reset that variable "cookie control_text"

i found it in the database-tables with phpmyadmin ... but have now clue how to "reset" it ?

budda’s picture

in the latest dev snapshot if you delete all text from the settings fields (there's two now) it will reset it to using the default translatable text unless overridden for the site.

How are you browsing the database? devel.module gives you a simple way to meddle with Drupal database variables through the UI.

bavarian’s picture

all text from the 2 settings field deleted with help of devel.module ...

the 2 text strings translated, but now ... none of these 2 text strings shows up, neither in original English, nor any of the translated languages ..

budda’s picture

just to confirm, in devel you cannot see the variables saved in the list at all ?

budda’s picture

Assigned: Unassigned » budda
Status: Needs work » Needs review

I've just pushed a small update up to the Git repo, which will be available in the dev snapshot tomorrow probably. It may help in translating any text that's entered through the admin UI.

bavarian’s picture

oh yes, i could see the variables and edit/change them (delete the english text)

budda’s picture

give v1.4 a try.

bavarian’s picture

v1.4 that was released yesterday or the dev-release from yesterday?

bavarian’s picture

I guess I am giving up on this module ...

thanks for your attempts !

budda’s picture

Status: Needs review » Closed (won't fix)
Miszel’s picture

There is now a D7 release of EU Cookie Compliance: http://drupal.org/project/eu-cookie-compliance. It is a bit different from Cookie Control but it may meet your needs as it supports multilingual sites.

bavarian’s picture

thanks for the information Marcin !

lmeurs’s picture

@Bavarian: Restoring a default value can most often be done by deleting the value and saving the form.

Peacog’s picture

Status: Closed (won't fix) » Closed (fixed)

My site has 5 languages and I have successfully translated all text via standard i18n string translation at admin/config/regional/translate/translate. Changing status of this to closed (fixed).

budda’s picture

I've declared the two text variables in the hook_variable_info() for what it's worth.

Matt B’s picture

Version: 7.x-1.6 » 7.x-1.x-dev

I cannot find the following strings at admin/config/regional/translate/translate

Privacy Policy
Cookies are on
Cookies are off
read less

I can find 'read more' and translate it (to 'lire plus'). When I click on it, it says 'read less', click on this and it reverts to 'read more' (not the translated string.

I had to hack the module to fix this (not ideal!). Line 97 of cookiecontrol.module is
$cookiecontrol_fulltext .= t('<p>By using our site you accept the terms of our !privacynode.', array('!privacynode' => l('Privacy Policy', 'node/' . $nid)));
The words 'Privacy Policy' are not translatable.

'Cookies are on/off' and 'read more/less' are all embedded in the js/cookieControl-5.1.min.js script. These need to be parameters.

I also had to hack the width style setting for .ccc-outer in the js file as my translation of 'Cookie Control' ran into the close (X) button on the right of the title, so the width also needs to be configurable.

Matt B’s picture

Version: 7.x-1.x-dev » 7.x-1.6
Status: Closed (fixed) » Needs work
budda’s picture

Version: 7.x-1.x-dev » 7.x-1.6

The CSS hacking in the javascript is something i don't want to meddle with as the JS is a 3rd party bit of code.

Good catch on the l() missing a t(). Not sure how that got missed!

gapa’s picture

First I used http://jsbeautifier.org on cookieControl-5.1.min.js so I could read the code. Then I fixed few lines. I added Drupal.t() function. I changed all lines where cookieOnText, cookieOffText are called and where f.text (for "read more" and "read less") is used. Now it works.
Hope it helps.

fugazi’s picture

Issue summary: View changes

I had the same problem with Privacy Policy. I have now solved

$cookiecontrol_fulltext .= t('<p>By using our site you accept the terms of our !privacynode.', array('!privacynode' => l('Privacy Policy', 'node/' . $nid)));

change in

$cookiecontrol_fulltext .= t('<p>By using our site you accept the terms of our !privacynode.', array('!privacynode' => l((t('Privacy Policy')), 'node/' . $nid)));

creatile’s picture

I had the same problem
#34 code works for me in cookiecontrol.module

Thanks

Anonymous’s picture

Can someone dumb that down for a beginner? I am looking for translations to "cookies are on", "cookies are off", "(ticking this...)" and so on. I tried the cookiecontrol translation on drupal and imported that, but it didn't change anything. Any other way than to modify the module-file?
Thank you

M.J.’s picture

FileSize
2.08 KB

A little patch for last problem translation, please include this in next release.

Denes.Szabo’s picture

Sorry guys, but this is very wrong practice:

$cookiecontrol_text = addslashes(t(variable_get('cookiecontrol_text', COOKIECONTROL_TEXT)));
     $cookiecontrol_fulltext = addslashes(t(variable_get('cookiecontrol_fulltext', COOKIECONTROL_FULLTEXT)));
+    $cookiecontrol_cookieontext = addslashes(t(variable_get('cookiecontrol_cookieontext', 'Cookies are on')));
+    $cookiecontrol_cookieofftext = addslashes(t(variable_get('cookiecontrol_cookieofftext', 'Cookies are off')));

The PhpCs says: Only string literals should be passed to t() where possible - in Drupal mode.

So, do not pass variable text into the t() function. This module should use Variable translation for translate texts stored in variables.

kewesley’s picture

The attached patch uses variable translation for the text "Cookies are on" and "Cookies are off" and removes the unnecessary t() calls from the variables mentioned in #38 (which already use variable translation).

It also amends the js file to pick up "read more" and "read less" as translatable strings.