Atenção!

Este artigo contém código PHP e destina-se a desenvolvedores. Oferecemos este código como uma cortesia, mas não fornecemos suporte para personalizações de código ou desenvolvimento de terceiros.

Para orientação extra, consulte o tutorial do WPBeginner sobre como adicionar código personalizado.

Dispensar

Como Alterar as Configurações de Idioma do Google reCAPTCHA

Would you like to customize the language of Google’s v2 reCAPTCHA on your forms? While Google attempts to auto-detect your page’s language, sometimes you may need to manually set it.

This guide will show you how to set a specific language for your reCAPTCHA using a simple code snippet.

Requisitos:

Setting the Language

To set a specific language for your reCAPTCHA, add this code to your site. For help adding code snippets, please see this tutorial on adding custom PHP or JavaScript.

Este código funciona:

  1. Intercepting the reCAPTCHA URL before it loads
  2. Adding the language parameter (‘hl’) with your specified language code
  3. Returning the modified URL with proper escaping for security

‘hl’ is Google’s parameter for setting the language (stands for “host language”), and ‘fr’ is the language code for French.

To use a different language:

  1. On line 10, replace ‘fr‘ with your desired language code
  2. Find your language code in Google’s documentation on reCAPTCHA Language Codes

After adding the code, the reCAPTCHA text (like “I’m not a robot“) will appear in your chosen language.

Multi-Language Support

For sites using WPML, you can use this alternative code that automatically matches your WPML language settings:

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.

Filtro de Referência

wpforms_frontend_recaptcha_url