Closed critcat closed 3 years ago
You should install the Symfony Translation component. Then replace the validation text with the translation keys for the message and messageMissingValue options:
#config/validator/validation.yaml
App\Entity\YourEntity:
properties:
captcha:
- Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3:
message: 'karser_recaptcha3.message'
messageMissingValue: 'karser_recaptcha3.message_missing_value'
Add English, Spanish, or any other translation:
# translations/validators/validators.en.yaml
karser_recaptcha3.message: 'Your computer or network may be sending automated queries'
karser_recaptcha3.message_missing_value: 'The captcha value is missing'
# translations/validators/validators.es.yaml
karser_recaptcha3.message: 'Es posible que su computadora o red esté enviando consultas automatizadas'
karser_recaptcha3.message_missing_value: 'Falta el valor de captcha'
Please let me know if it worked for you.
Thank you for your quick response!
I tried using the settings in config/validator/validation.yaml file, but this throws a 500 error
Property "captcha" does not exist in class "App\Entity\User"
Instead, I changed the code in the form class:
->add('captcha', Recaptcha3Type::class, [
'constraints' => new Recaptcha3 ([
'message' => 'karser_recaptcha3.message',
'messageMissingValue' => 'karser_recaptcha3.message_missing_value',
]),
'action_name' => 'registration',
])
And it worked great.
I'm glad it worked for you :+1:
How can I set the captcha language for different locales? Is there some option for this?