contact-form-7-recaptcha

Change the language of reCAPTCHA in Contact Form 7

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

8 comments

Leave a Reply

  1. jankkan · April 21

    Thank you, works like a charm!

    • janoshke · April 21

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

  2. Michael Animashaun · April 21

    Thanks worked like a charm

  3. Andrea Tarricone · April 21

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

    • janoshke · April 21

      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 · April 21

    Excellent! Thanks for helping πŸ™‚