Skip to content

Commit 227cc54

Browse files
authored
Merge pull request #215 from AppSaloon/fix/214-cookie_types-is-not-localized
Fix/214 cookie types is not localized
2 parents f111b75 + 7d9cc33 commit 227cc54

File tree

6 files changed

+381
-29
lines changed

6 files changed

+381
-29
lines changed

addons/lib/helper.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,29 @@ function cookiebot_addons_get_language() {
306306
return $lang;
307307
}
308308

309+
/**
310+
* @param array $cookie_names
311+
*
312+
* @return array
313+
*/
314+
function cookiebot_translate_cookie_names($cookie_names) {
315+
$translated_cookie_names = array(
316+
'preferences' => esc_html__('preferences', 'cookiebot'),
317+
'statistics' => esc_html__('statistics', 'cookiebot'),
318+
'marketing' => esc_html__('marketing', 'cookiebot'),
319+
);
320+
return array_map(
321+
function(string $cookie_name) use ($translated_cookie_names) {
322+
$cookie_name = trim($cookie_name);
323+
if(isset($translated_cookie_names[$cookie_name])) {
324+
return $translated_cookie_names[$cookie_name];
325+
}
326+
return $cookie_name;
327+
},
328+
$cookie_names
329+
);
330+
}
331+
309332
/**
310333
* Get supported languages by the cookiebot
311334
*

addons/lib/settings-service.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,11 @@ private function get_translated_placeholder( $option, $option_key, $default_plac
395395
* if current lang match with the prefix language in the database then get the text
396396
*/
397397
if ( $key == $current_lang ) {
398+
$cookies_array = explode(', ',$cookies);
399+
$translated_cookie_names = cookiebot_translate_cookie_names($cookies_array);
400+
$translated_cookie_names = implode(', ', $translated_cookie_names);
398401
return $this->placeholder_merge_tag( $option[ $option_key ]['placeholder']['languages'][ $key ],
399-
$cookies, $src );
402+
$translated_cookie_names, $src );
400403
}
401404
}
402405
}

langs/cookiebot-da_DK.mo

126 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)