@@ -35,6 +35,7 @@ class EiCaptcha extends Module
35
35
36
36
/** @var array */
37
37
protected $ themes = [];
38
+
38
39
/**
39
40
* @var Debugger
40
41
*/
@@ -45,6 +46,11 @@ class EiCaptcha extends Module
45
46
*/
46
47
protected $ installer ;
47
48
49
+ /**
50
+ * @var string (2 or 3 digits Language ISO code) Captcha language (default: en)
51
+ */
52
+ protected $ captchaLang = 'en ' ;
53
+
48
54
public function __construct ()
49
55
{
50
56
$ this ->author = 'hhennes ' ;
@@ -70,6 +76,12 @@ public function __construct()
70
76
$ this ->ps_versions_compliancy = ['min ' => '1.7.0.0 ' , 'max ' => _PS_VERSION_ ];
71
77
72
78
$ this ->debugger = new Debugger ($ this );
79
+
80
+ $ this ->captchaLang = $ this ->context ->language ->iso_code ;
81
+ $ forceLang = Configuration::get ('CAPTCHA_FORCE_LANG ' );
82
+ if (!empty ($ forceLang ) && Validate::isLanguageIsoCode ($ forceLang )) {
83
+ $ this ->captchaLang = $ forceLang ;
84
+ }
73
85
}
74
86
75
87
/**
@@ -213,7 +225,7 @@ protected function renderHeaderV2()
213
225
</script> ' ;
214
226
215
227
if (($ this ->context ->controller instanceof ContactController && Configuration::get ('CAPTCHA_ENABLE_CONTACT ' ) == 1 )) {
216
- $ js .= '<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit&hl= ' . Configuration:: get ( ' CAPTCHA_FORCE_LANG ' ) . '" async defer></script> ' ;
228
+ $ js .= '<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit&hl= ' . $ this -> captchaLang . '" async defer></script> ' ;
217
229
}
218
230
219
231
return $ js ;
@@ -260,8 +272,8 @@ public function hookDisplayCustomerAccountForm($params)
260
272
$ this ->context ->smarty ->assign ([
261
273
'captchaVersion ' => Configuration::get ('CAPTCHA_VERSION ' ),
262
274
'publicKey ' => Configuration::get ('CAPTCHA_PUBLIC_KEY ' ),
263
- 'captchaforcelang ' => Configuration:: get ( ' CAPTCHA_FORCE_LANG ' ) ,
264
- 'captchatheme ' => $ this ->themes [Configuration::get ('CAPTCHA_THEME ' )],
275
+ 'captchalang ' => $ this -> captchaLang ,
276
+ 'captchatheme ' => $ this ->themes [Configuration::get ('CAPTCHA_THEME ' )]
265
277
]);
266
278
267
279
return $ this ->display (__FILE__ , 'views/templates/hook/hookDisplayCustomerAccountForm.tpl ' );
@@ -357,8 +369,8 @@ public function hookDisplayNewsletterRegistration($params)
357
369
$ this ->context ->smarty ->assign ([
358
370
'captchaVersion ' => Configuration::get ('CAPTCHA_VERSION ' ),
359
371
'publicKey ' => Configuration::get ('CAPTCHA_PUBLIC_KEY ' ),
360
- 'captchaforcelang ' => Configuration:: get ( ' CAPTCHA_FORCE_LANG ' ) ,
361
- 'captchatheme ' => $ this ->themes [Configuration::get ('CAPTCHA_THEME ' )],
372
+ 'captchalang ' => $ this -> captchaLang ,
373
+ 'captchatheme ' => $ this ->themes [Configuration::get ('CAPTCHA_THEME ' )]
362
374
]);
363
375
364
376
return $ this ->display (__FILE__ , 'views/templates/hook/hookDisplayNewsletterRegistration.tpl ' );
@@ -437,7 +449,7 @@ public function hookActionGetEicaptchaParams($params)
437
449
'captchaVersion ' => Configuration::get ('CAPTCHA_VERSION ' ),
438
450
'publicKey ' => Configuration::get ('CAPTCHA_PUBLIC_KEY ' ),
439
451
'captchaforcelang ' => Configuration::get ('CAPTCHA_FORCE_LANG ' ),
440
- 'captchatheme ' => $ this ->themes [Configuration::get ('CAPTCHA_THEME ' )],
452
+ 'captchatheme ' => $ this ->themes [Configuration::get ('CAPTCHA_THEME ' )]
441
453
];
442
454
}
443
455
@@ -454,8 +466,8 @@ public function hookDisplayEicaptchaVerification($params)
454
466
'displayCaptcha ' => $ this ->shouldDisplayToCustomer (),
455
467
'captchaVersion ' => Configuration::get ('CAPTCHA_VERSION ' ),
456
468
'publicKey ' => Configuration::get ('CAPTCHA_PUBLIC_KEY ' ),
457
- 'captchaforcelang ' => Configuration:: get ( ' CAPTCHA_FORCE_LANG ' ) ,
458
- 'captchatheme ' => $ this ->themes [Configuration::get ('CAPTCHA_THEME ' )],
469
+ 'captchalang ' => $ this -> captchaLang ,
470
+ 'captchatheme ' => $ this ->themes [Configuration::get ('CAPTCHA_THEME ' )]
459
471
]);
460
472
461
473
return $ this ->display (__FILE__ , 'views/templates/hook/hookDisplayEicaptchaVerification.tpl ' );
0 commit comments