acf-recaptcha icon indicating copy to clipboard operation
acf-recaptcha copied to clipboard

Change locale

Open vitalijm opened this issue 7 years ago • 5 comments

Hi, thanks for the plugin.

How we can change locale? Maybe is some add_filter for this?

vitalijm avatar Feb 26 '18 08:02 vitalijm

Hi @vitalijm, what do you mean by locale? Do you mean language or something?

irvinlim avatar Feb 27 '18 18:02 irvinlim

Yes @irvinlim, language. I can't find where or how to show recaptcha in other language.

vitalijm avatar Feb 28 '18 05:02 vitalijm

The language of the reCAPTCHA widget should be automatically loaded based on the user's locale.

There seems to be a way to fix the language though: https://developers.google.com/recaptcha/docs/display

Is this what you are looking for?

irvinlim avatar Feb 28 '18 16:02 irvinlim

I need something like:

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 );
}

Where most important part of code is "'hl' => 'fr-CA'", with this I can now modify recaptcha display language.

Or realize logic with add_filter, I don't know what in your situation is better.

vitalijm avatar Mar 01 '18 06:03 vitalijm

I currently don't have the bandwidth to work on this plugin. If you wish you can create a PR to add an ACF option to modify the hl parameter when fetching api.js.

The list of language codes is here: https://developers.google.com/recaptcha/docs/language

irvinlim avatar May 05 '18 11:05 irvinlim