add_filter('wpcf7_validate', 'custom_cf7_error_messages', 10, 2);
function custom_cf7_error_messages($result, $tags) {
$current_lang = pll_current_language();
if ($current_lang == 'en') {
if (isset($result->messages['invalid_required'])) {
$result->messages['invalid_required'] = 'This field is required';
}
if (isset($result->messages['invalid_email'])) {
$result->messages['invalid_email'] = 'Please enter a valid email address';
}
}
return $result;
}