How to Set the Language for Google reCAPTCHA

Would you like to set the language for Google’s v2 reCAPTCHA? Google will try and auto-detect the language on the page when using reCAPTCHA. In some cases, its detection doesn’t work and in other use cases, you may just want to force it to something different. With a small PHP snippet, you can easily set the language inside a filter.

Setting the language

In our code example below, we’re going to set the reCAPTCHA language to French (FR).

First, you’ll need to set up Google v2 reCAPTCHA on your form. If you need any assistance with that, please view this tutorial.

Next, you’ll need to copy this code to your site. If you need help in adding snippets to your site, please see this tutorial.

 * Set the language for Google reCAPTCHA.
 * @link

function wpf_dev_recaptcha_language( $url ) {

        // Set the language code to FR (French)
	return esc_url_raw( add_query_arg( array( 'hl' => 'fr '), $url ) );

add_filter( 'wpforms_frontend_recaptcha_url', 'wpf_dev_recaptcha_language', 10, 1);

Once the code is added, you can now see the I’m not a robot question has been translated to French.

now the language for google recaptcha is set to french

And that’s all you need to force the reCAPTCHA language. Would you like to also change the look of reCAPTCHA? Take a look at our article on How to Change the Captcha Theme on Google Checkbox v2 reCAPTCHA.

Reference Filter



Q: What if I have a multi-lingual site with WPML?

A: If you are providing multiple languages on your site, you would want to use this code snippet for WPML and multi-language sites.

* Set a specific language Google reCAPTCHA.
* @link

function wpf_dev_recaptcha_language_wpml( $url ) {
	// Get my current language setting from WPML
	$my_current_lang = apply_filters( 'wpml_current_language', NULL );
	// Set the language of my Google reCAPTCHA to the same language that I have set in WPML
	return esc_url_raw( add_query_arg( array( 'hl' => $my_current_lang ), $url ) );

add_filter('wpforms_frontend_recaptcha_url', 'wpf_dev_recaptcha_language_wpml', 10, 1);