This thread is resolved. Here is a description of the problem and solution.
Problem: You are trying to translate the Google reCAPTCHA from English to Arabic on your website but are unsure how to proceed since WPML does not handle the translation of external services like Google reCAPTCHA. Solution: The language of the Google reCAPTCHA widget is controlled by Google's API parameters. Since this widget is embedded directly into your theme's template files and not managed by a plugin or Elementor, you will need to adjust the API call to specify the desired language. This involves modifying the src attribute in the reCAPTCHA iframe to include the language parameter. For example, to set the language to Arabic, you can modify the src URL as follows:
Please note that this solution might be outdated or not applicable to your specific case. If this does not resolve your issue, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket with us.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Background of the issue:
I'm trying to translate the English captcha box to Arabic on my site hidden link. The English version of the captcha is shown in this image: hidden link, and the Arabic version is shown here: hidden link. The live URL for this is hidden link (Click 'create new account' to see the versions).
Symptoms:
I don't know how to translate the captcha box from English to Arabic.
Questions:
How can I translate the captcha box from English to Arabic using WPML?
Languages: English (English )German (Deutsch )French (Français )
Timezone: Europe/Zagreb (GMT+02:00)
Hi,
There are two ways CAPTCHA text can work on the site:
1. If the site uses an external service such as Google reCAPTCHA, hCaptcha, or Cloudflare Turnstile, the text comes from that service. It usually changes automatically based on the visitor’s browser language, not WPML, so it is not possible to translate it.
2. If the CAPTCHA is part of a plugin like Contact Form 7, WPForms, or Really Simple CAPTCHA, the static text (for example, “Enter the text”) can be translated with WPML. The random code itself is always the same.
Could you let me know which CAPTCHA system the site is using so I can confirm how the translations will work?
Languages: English (English )German (Deutsch )French (Français )
Timezone: Europe/Zagreb (GMT+02:00)
That is a Google reCAPTCHA iframe. The src attribute points to hidden link?..., which is the official Google reCAPTCHA service.
The reCAPTCHA widget’s language is controlled by Google’s API parameters and from what I see, you don't have a plugin for this, it is not even part of the Elementoror template for this page hidden link, this is all coded directly into the theme template files (function call for the reCAPTCHA). hidden link
WPML (or any other multilingual plugin for that matter) can translate your site’s content, but they do not translate the Google reCAPTCHA widget itself.
Hi Bruno thanks for this. The issue is that the captcha does not appear on the arabic version - it disappears - is this something to do with how the child theme is translated at all?
Languages: English (English )German (Deutsch )French (Français )
Timezone: Europe/Zagreb (GMT+02:00)
I see that on arabic there is a "window.onload_recaptcha_callback is not defined. Check functions.php for reCAPTCHA script enqueue and inline script." error recorded in the console.
That error usually happens when reCAPTCHA is being loaded twice (once by default, once by your code) or when WPML changes the page language, but the onload callback is not defined before reCAPTCHA tries to run. In this case it is likely the later.
Maybe something like this could work (add all of this into the functions.php):
function add_recaptcha_callback_script() {
?>
<script>
function recaptcha_login_callback(token) {
// Save the token into hidden field
document.getElementById('recaptcha_response_login').value = token;
}
</script>
<?php
}
add_action('wp_footer', 'add_recaptcha_callback_script');
function load_recaptcha_with_language() {
if ( defined('ICL_LANGUAGE_CODE') ) {
$lang = ICL_LANGUAGE_CODE; // WPML language code (e.g. ar, en, fr)
} else {
$lang = 'en'; // fallback
}
wp_enqueue_script(
'google-recaptcha',
'<em><u>hidden link</u></em>' . esc_attr($lang),
array(),
null,
true
);
}
add_action('wp_enqueue_scripts', 'load_recaptcha_with_language');
But this is just a possible theory. Given that all this is coded directly into the theme, so quite a lot of custom code which we don't support according to our support rules, can you check with developers of the theme about this?
Let me know what they say, in case they are unable to resolve it.
Bruno - thank you so much for these suggestions! I'm putting them to the developer of the pages / survey in question - hopefully they will be able to work from your suggestions and make appropriate edits. Thanks again.
Languages: English (English )German (Deutsch )French (Français )
Timezone: Europe/Zagreb (GMT+02:00)
I’m glad to hear the suggestions are with the developer. They should serve as a solid starting point, though some adjustments may be required depending on the setup. If any clarification or further support is needed during implementation, please let me know.
Hi Bruno, developer was able to work with your suggestions and has now edited the pages so that the captcha can be included. Many thanks for all your help.