get_locale() and translation functions __() not working
-
Hi,
This code below is taking precedence over my custom functions, so get_locale() and translation functions __() are no longer working. I’m using Polylang free version, and I basically create a form for each language and then add it to the page. So for example when I am on a French page, I add the French contact form shortcode.
Here’s the most recent CF7 code causing the issue:
$output = wpcf7_switch_locale( $contact_form->locale(), $callback, $contact_form, $atts );
Here’s what fixes the issue:
$output = wpcf7_switch_locale( get_locale(), $callback, $contact_form, $atts );
I’m doing some workarounds like so but I still have issues with _() translation functions. And I’m not only using it in wpcf7_form_hidden_fields hook, also in wpcf7_init to create custom tags, wpcf7_add_form_tag.
$current_locale = get_locale(); add_filter( 'wpcf7_form_hidden_fields', function( $hidden_fields ) use ( $current_locale ) { return filter_wpcf7_form_hidden_fields( $hidden_fields, $current_locale ); }, 10, 1 );
Is this the proper way to pull the language from the form and not instead from the actual page so it matches the page language? If is the way, can I somehow hook into to change the locale? Thank you.
- You must be logged in to reply to this topic.