diff --git a/src/RecaptchaServiceProvider.php b/src/RecaptchaServiceProvider.php index df0b5f7..5e261e7 100644 --- a/src/RecaptchaServiceProvider.php +++ b/src/RecaptchaServiceProvider.php @@ -35,12 +35,16 @@ public function boot() */ public function addValidator() { + $translator = app('translator'); + $translator->addNamespace('recaptcha', __DIR__ . '/lang'); + $translator->load('recaptcha', 'recaptcha', $translator->locale()); + $this->app->validator->extendImplicit('recaptcha', function ($attribute, $value, $parameters) { $captcha = app('recaptcha.service'); $challenge = app('request')->input($captcha->getResponseKey()); return $captcha->check($challenge, $value); - }, 'Please ensure that you are a human!'); + }, $translator->get('recaptcha::recaptcha.error')); } /** diff --git a/src/lang/en/recaptcha.php b/src/lang/en/recaptcha.php new file mode 100644 index 0000000..65726cc --- /dev/null +++ b/src/lang/en/recaptcha.php @@ -0,0 +1,5 @@ + 'Please ensure that you are a human!' +]; diff --git a/src/lang/fr/recaptcha.php b/src/lang/fr/recaptcha.php new file mode 100644 index 0000000..7a9e7f5 --- /dev/null +++ b/src/lang/fr/recaptcha.php @@ -0,0 +1,5 @@ + 'Merci de vĂ©rifier que vous ĂȘtes un humain!' +];