The Contact Form 7 for WordPress is a nice simple plugin to build contact forms fast. But when it comes to making it completely multilingual it lacks a bit.
I am currently creating a website with 13 different languages, that would mean to create the same contact form 13 times, not really practical :)
I am translating the form labels on the fly with some javascript magic, but for the messages I had to go a bit deeper.
public function message( $status ) { $messages = $this->messages; $message = $this->replace_mail_tags( $message, true ); return apply_filters( 'wpcf7_display_message', $message, $status); }
to this
public function message( $status ) { $messages = $this->messages; $message = $this->replace_mail_tags( $message, true ); return __(apply_filters( 'wpcf7_display_message', $message, $status ),'textdomain'); }
See how I wrapped the gettext function for the return, that does all the magic.
'msg_1' => __('Your message was sent successfully. Thanks.','textdomain'), 'msg_2' => __('Failed to send your message. Please try later or contact the administrator by another method.','textdomain'), 'msg_3' => __('Validation errors occurred. Please confirm the fields and submit it again.','textdomain'), );
Cheers
Alex
What are particle animations? Particle network animations in JavaScript typically involve creating visual representations of… Read More
BOOKING SOLUTIONS 202x This is my take on a subset of booking, appointment, PMS or… Read More
THE GOAL Create a system cron for WordPress, that is accessible and can be easily… Read More
2024, what's cooking? Slowly getting into the 2024 spirit. 3 projects coming to a close… Read More
Short look back at 2023 This has been a busy and interesting year. I am… Read More
Elementor Pro provides grid containers as an experimental feature. The options provided are limited, when… Read More