Setting recaptcha in a different language other than english

后端 未结 6 2303
南笙
南笙 2021-02-13 20:37

Is it me or is recaptcha images cannot be translated to another language other than EN? I have \"enter

相关标签:
6条回答
  • 2021-02-13 20:40

    For recapture 2 just add script file with your language:

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

    Language codes here: https://developers.google.com/recaptcha/docs/language

    0 讨论(0)
  • 2021-02-13 20:40

    You just have to add this function above to your theme's function.php file and all done. It really works for me, you can change translation language by modifying country code in hl parameter.

    Here i'm using es here for Spanish translation.

    This is a list of language country codes: https://developers.google.com/recaptcha/docs/language

    function wptricks24_recaptcha_scripts() {
        wp_deregister_script( 'google-recaptcha' );
    
        $url = 'https://www.google.com/recaptcha/api.js';
        $url = add_query_arg( array(
            'onload' => 'recaptchaCallback',
            'render' => 'explicit',
            'hl' => 'es'), $url ); // es is the language code for Spanish language
    
        wp_register_script( 'google-recaptcha', $url, array(), '2.0', true );
    }
    
    add_action( 'wpcf7_enqueue_scripts', 'wptricks24_recaptcha_scripts', 11 );
    
    0 讨论(0)
  • 2021-02-13 20:44

    For reCAPTCHA 2. Since a while have passed

    This is your link to cdn look at the end, hl parameter

    <script src="https://www.google.com/recaptcha/api.js?onload=myCallBack&render=explicit&hl=fr" async defer></script>
    

    This is your captcha inside the form

    <div id="recaptcha1"></div>
    

    This is your javascript you can specify the lang code here too, I assume one of them is enough

    var recaptcha1;
    var myCallBack = function() {
        //Render the recaptcha1 on the element with ID "recaptcha1"
        recaptcha1 = grecaptcha.render('recaptcha1', {
        'sitekey': '6LdJLws_your site key',
        'lang' : 'fr'
       });};
    

    You can add multiple reCAPTCHAs with this method.

    Here is full language reference: https://developers.google.com/recaptcha/docs/language?hl=en

    0 讨论(0)
  • 2021-02-13 20:44

    Just to minimize the answers above.

    It's not necessary to additionally add another <script> saying the same as you already do with your html (reCAPTCHA) element. Changing the link of the API will also work.

    <script src="https://www.google.com/recaptcha/api.js?explicit&hl=nl"></script>

    For me I've changed the language code to nl(dutch) after &hl=. But you can find your own language code at: https://developers.google.com/recaptcha/docs/language

    0 讨论(0)
  • 2021-02-13 20:52

    Look at this page, rolling down and you will get the answer : https://developers.google.com/recaptcha/docs/customization

    On your page where you show up the captcha for clients, within the <form> and before the reCaptcha widget, you add this code :

    <script type="text/javascript">
    var RecaptchaOptions = {
       lang : 'fr',
    };
    </script>
    

    The following languages are supported:

    English en / Dutch nl / French fr / German de / Portuguese pt / Russian ru / Spanish es / Turkish tr

    Hope it helps you...

    0 讨论(0)
  • 2021-02-13 20:58

    replace lang to hl and it'll work:

    <script type="text/javascript">
    var recaptcha1;
    var myCallBack = function() {
        //Render the recaptcha1 on the element with ID "recaptcha1"
        recaptcha1 = grecaptcha.render('recaptcha1', {
            'sitekey': '6LdJLws_your site key',
            'hl' : 'fr'
        });
    };
    </script>
    
    0 讨论(0)
提交回复
热议问题