Change the language of reCAPTCHA in Contact Form 7

contact-form-7-recaptcha

Written by

in

This issue is resolved long time ago and for those who are using one of the best WordPress plugin called Contact Form 7 and didn’t read the developer’s post on the topic, here is how to change the language of reCAPTCHA.

In this example I’m using the French (Canadian) language and the text that Google reCAPTCHA displays in English as “I’m not a robot” needs to be displayed in French. Here is the very simple solution for this:

1. Edit the functions.php file

Locate the file functions.php in your theme folder (or child theme) and add the following code at the end:

add_action( 'wpcf7_enqueue_scripts', 'custom_recaptcha_enqueue_scripts', 11 );

function custom_recaptcha_enqueue_scripts() {
	wp_deregister_script( 'google-recaptcha' );

	$url = 'https://www.google.com/recaptcha/api.js';
	$url = add_query_arg( array(
		'onload' => 'recaptchaCallback',
		'render' => 'explicit',
	 	'hl' => 'fr-CA' ), $url );

	wp_register_script( 'google-recaptcha', $url, array(), '2.0', true );
}

Note that the fr-CA is the language code for French (Canadian) so you must change it according to your needs and the list of supported language codes can be found here

Comments

20 responses to “Change the language of reCAPTCHA in Contact Form 7”

  1. jankkan Avatar

    Thank you, works like a charm!

    1. janoshke Avatar

      I’m glad it helped!
      Cheers πŸ˜‰

  2. Michael Animashaun Avatar

    Thanks worked like a charm

    1. janoshke Avatar

      Great! Cheers πŸ™‚

  3. Andrea Tarricone Avatar

    Hello! Could you please make an IF/ELSE version that read the html lang= TAG and shows the assigned laguage?

    1. janoshke Avatar

      Thanks for the comment, but this is something Google programmers should do. I’m sure they will make this multilanguage work in near future.
      Cheers πŸ˜‰

  4. saxotenor Avatar
    saxotenor

    Excellent! Thanks for helping πŸ™‚

    1. janoshke Avatar

      You’re welcome. Cheers πŸ™‚

  5. Aleksandra Avatar
    Aleksandra

    Thank you!

    1. janoshke Avatar

      You’re welcome πŸ™‚

    1. janoshke Avatar

      You’re welcome. πŸ™‚

  6. Jerry Avatar
    Jerry

    This does not work for me. Recaptcha language stays english even after function.php edit and restart apache2 + browser.

    1. janoshke Avatar

      Sorry to hear that. If you wish to share more info please do so…

  7. Almedin Avatar
    Almedin

    Hi, this code does not work anymore. Now Really Simple Captcha work with google reCaptcha v3. Are you able to modify this code for new reCaptcha version. Thanks.

    1. janoshke Avatar

      Hi, it is possible that the code is deprecated. I will post the update some time in near future πŸ˜‰

  8. Yuvraj Khavad Avatar

    Wow, Working like king. Thank you

    1. janoshke Avatar

      You’re welcome. Cheers πŸ˜‰

  9. Kurdo Avatar
    Kurdo

    than you so much

    1. janoshke Avatar

      You’re welcome πŸ™‚

Leave a Reply