Setting reCAPTCHA Version 2 set another language other than English

Yes, the "hl=language code" approach works well. The catch, of course, is to do this to EVERY instance of <script src='https://www.google.com/recaptcha/api.js'></script> on the page - both the one in the page head AND the one in the body. Only putting hl=... in the body leads to inconsistent results.


Simple solution

You can do it like this:

HTML

<div id="captcha_container"></div>
<select id="ddllanguageListsGoogleCaptcha"></select>

JS

// Update language captcha 
function updateGoogleCaptchaLanguage(selectedLanguage) {

    // Get GoogleCaptcha iframe
    var iframeGoogleCaptcha = $('#captcha_container').find('iframe');

    // Get language code from iframe
    var language = iframeGoogleCaptcha.attr("src").match(/hl=(.*?)&/).pop();

    // Get selected language code from drop down
    var selectedLanguage = $('#ddllanguageListsGoogleCaptcha').val();

    // Check if language code of element is not equal by selected language, we need to set new language code
    if (language !== selectedLanguage) {
        // For setting new language 
        iframeGoogleCaptcha.attr("src", iframeGoogleCaptcha.attr("src").replace(/hl=(.*?)&/, 'hl=' + selectedLanguage + '&'));
    }
}

Online demo (jsFiddle)


You just need to specify the parameter "?hl=" in the script's url:

<script src='https://www.google.com/recaptcha/api.js?hl=fr'></script>

Not very well documented, indeed!

find your language code here: https://developers.google.com/recaptcha/docs/language


If you are using the recaptcha gem you need to provide the hl param in recaptcha_tags.

Example:

<%= recaptcha_tags ssl: true, hl: 'it', display: { theme: 'white' } %>