Translate Email forms plugin's Validation Messages

Hello, would you be so kind to tell me how I can insert the translations of the validation messages located into subscribe.php (tco-email-forms > email-integration > functions > shortcodes > subscribe.php) into the function.php file of the child theme?

thank you so much!

The string is this

if ( is_wp_error( $result ) ) {
$message = $result->get_error_message() == 'Member Exists'
               ? __( '**We were unable to add your email to the list: this email is already on the list.**', '__tco__' )
               : $result->get_error_message(); //__( '**We\'re sorry! Something went wrong. We were unable to add your email to the list. Please try again later.**', '__tco__' );
      $response = array(
        'error'       => true,
        'log_message' => $result->get_error_message(),
        'message'     => $message
      );
    }

Hey @scvizar,

Thanks for writing in!

Assuming the child theme is set up, please add the following code in your child theme’s functions.php file

// Translate Text
function translate_text( $translated_text, $text, $domain ) {
  $translated = str_ireplace('**We were unable to add your email to the list: this email is already on the list.**', 'insert your translation here', $translated);
    return $translated; 
}
add_filter( 'gettext', 'translate_text');
//

Hope this helps.

thank you, but it doesn’t work. Now the validation message appears as an empty rectangle.
Any advice?

Hi, I think there’s a small typo (this happens at times) in the original code posted. Please update it to this:

// Translate Text
function translate_text( $translated_text, $text, $domain ) {
  $translated = str_ireplace('**We were unable to add your email to the list: this email is already on the list.**', 'insert your translation here', $translated_text);
    return $translated; 
}
add_filter( 'gettext', 'translate_text');
//

Tell us if that works.

Cheers.

1 Like

Perfect! thank you so much!

You’re most welcome, @scvizar.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.