My website offers three different languages that users can switch between. The language switch functionality is implemented on the client side using JavaScript (AngularJS).
I have integrated reCAPTCHA 2 into my website and now I need to update the language of the reCAPTCHA when a user switches the language of the website.
I am aware that I can set the language during initialization of reCAPTCHA with this code:
<script src="https://www.google.com/recaptcha/api.js?hl=cs"></script>
However, when I need to reload reCAPTCHA, the following code is used which does not provide an option for specifying a custom language:
grecaptcha.reset();
Is there a way to accomplish this without refreshing the page or re-initializing the reCAPTCHA widget with a different language?
EDIT
I am using angular-recaptcha to display the widget. This means:
- I must call the
vcRecaptchaApiLoaded
callback after initializing the reCAPTCHA API - I cannot modify the code generated by the
vcRecaptcha
directive
This is the code responsible for rendering the reCAPTCHA widget:
<div
vc-recaptcha
key="'---- YOUR PUBLIC KEY GOES HERE ----'"
></div>
Here is the script to include the reCAPTCHA API in my website:
<script
src="https://www.google.com/recaptcha/api.js?onload=vcRecaptchaApiLoaded&render=explicit&hl=cs"
async defer
></script>