Google captcha as multilingual.

344 views
Skip to first unread message

Kumail Raza

unread,
Jan 30, 2017, 6:14:59 AM1/30/17
to reCAPTCHA
Recently I have requirement to change the language of google captcha to arabic.

I figure out that Google Captcha has the multilingual feature, but I tried different ways but no proper solution unless
a tweak came to my mind (but I believe not the right solution)

Normally : http://www.google.com/recaptcha/api.js?render=explicit

/* PLEASE DO NOT COPY AND PASTE THIS CODE. */
(function() {
if (!window['___grecaptcha_cfg']) {
window['___grecaptcha_cfg'] = {};
};
if (!window['___grecaptcha_cfg']['render']) {
window['___grecaptcha_cfg']['render'] = 'explicit';
};
window['__google_recaptcha_client'] = true;
var po = document.createElement('script');
po.type = 'text/javascript';
po.async = true;
po.src = 'https://www.gstatic.com/recaptcha/api2/r20170126104253/recaptch
a__en.js';
    var elem = document.querySelector('script[nonce]');
var nonce = elem && elem.getAttribute('nonce');
if (nonce) {
po.setAttribute('nonce', nonce);
}
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
thought of 


might it change 'en' to 'ar' but it always 'en'. I would like to know the best approach. Can you provide the solution?


Tim Heikell

unread,
Jan 30, 2017, 4:06:33 PM1/30/17
to reCAPTCHA

Evan Sharp

unread,
Feb 2, 2017, 9:45:42 AM2/2/17
to reCAPTCHA
Also, a hidden gem... if you explicitly render the reCaptcha widget, you can pass `hl` with the parameters object. It will download the right script and render in that language. It's not documented as a parameter, but does work.
Reply all
Reply to author
Forward
0 new messages