Setting reCAPTCHA Version 2 set another language other than English

后端 未结 5 487
走了就别回头了
走了就别回头了 2021-01-30 16:19

\"enter

How can I set this in another language, ie:. French

I\'ve tried:

5条回答
  •  盖世英雄少女心
    2021-01-30 16:47

    Simple solution

    You can do it like this:

    HTML

    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)

提交回复
热议问题