Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1193397

    danareeves
    Participant

    The error messages shown in the attached screenshots are showing up because the email address used is already subscribed and in the MailChimp list. Is there a way to change the actual wording of that error message? Right now it reads as though there’s a problem with the form, when really it’s that the email address is already subscribed.

    The forms are on http://the3gbook.com.

    Thanks for your help!

    #1193602

    Christian
    Moderator

    Hey Dana,

    Regretfully, the error generation in the Mailchimp addon is only generic. That means, it currently only treats all errors as one or only has one message for all errors encountered. There is a way to change that but please note your message should be generic also because if someone adds and invalid email for example, and your message is for “email already exist”, that would be inconsistent. To change the text, please add the code below in your functions.php

    function change_text( $translated_text, $text, $domain ) {
      switch ( $translated_text ) {
        case 'We\'re sorry! Something went wrong. We were unable to add your email to the list. Please try again later.' :
          $translated_text = __( 'Sorry, please check if your email is valid or you have already subscribed.', '__x__' );
          break;
      }
      return $translated_text;
    }
    add_filter( 'gettext', 'change_text', 20, 3 );

    Thanks.

    #1194020

    danareeves
    Participant

    Hi Christian,

    Uh oh… I added that code, and it made the site go down and I got this error message:

    Parse error: syntax error, unexpected ‘s’ (T_STRING), expecting ‘,’ or ‘)’ in /home/allisonn/public_html/the3gbook.com/wp-content/themes/x-child/functions.php on line 33

    I’ve removed that code from the functions.php file and the site is back up now. What should be different in that code?

    Thanks!

    #1194132

    Joao
    Moderator

    Hi There,

    Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:

    – Link to your site
    – WordPress Admin username / password
    – FTP credentials
    – Mailchimp Credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    Thanks

    Joao

    #1274799

    Mark M
    Participant

    Hello, I would also like to change the text of the error message, as it has confused a few of our subscribers.

    I would like for it to say, “Oops! It looks you have either already subscribed, or are submitting an invalid email. Please check again, and contact us if you have any concerns.”

    Can you please post the correct code for me to add to the functions php file?
    Thx!
    Emma

    #1274841

    Jade
    Moderator

    Hi Emma,

    Please try this code:

    add_filter('gettext', 'reword_mailchimp_error_message', 20, 3);
    function reword_mailchimp_error_message ( $translated, $text, $domain ) {
    return $text == 'We\'re sorry! Something went wrong. We were unable to add your email to the list. Please try again later.' ? 'YOUR NEW WORDING HERE' : $translated;
    }

    Hope this helps.

    #1276588

    Mark M
    Participant

    Thank you – that worked perfectly!
    Emma

    #1276595

    Nabeel A
    Moderator

    Glad we could help 🙂

    Cheers!

    #1412960

    Meng
    Participant

    Hey can I tag on to this thread? I’d like to know how I can preprare that code snippet for string translation through WPML. Because right now it doesn’t declare a text domain, so I can’t find it when I scan the theme for gettext strings to translate…

    #1413331

    Rad
    Moderator

    Hi there,

    Which string and how it’s implemented? Would you mind providing some details and screenshots?

    Thanks!

    #1414149

    Meng
    Participant

    I followed the above instructions exactly and pasted the following into my Child Theme’s functions.php file:

    
    add_filter('gettext', 'reword_mailchimp_error_message', 20, 3);
    function reword_mailchimp_error_message ( $translated, $text, $domain ) {
    return $text == 'We\'re sorry! Something went wrong. We were unable to add your email to the list. Please try again later.' ? 'YOUR NEW WORDING HERE' : $translated;
    }
    

    Now I want to translate “YOUR NEW WORDING HERE” with WPML String Translation. It uses gettext text-domains to identify strings to translate in their respective plugins and themes. This line however can’t be found no matter how much I scan the WP install for translateable strings.

    #1414731

    Christian
    Moderator

    That might be technically possible but would require additional custom development which is outside the scope of our support. You might want to contact our trusted partners who caters X setup and customization needs. Please see https://community.theme.co/custom-development/

    Thank you for understanding.

    #1421121

    Meng
    Participant

    Why? It’s just a simple matter of declaring a text domain. I don’t understand: if you are able to provide the aforementioned codelet for our convenience, how hard can it be to add a text-domain declaration properly so we can translate it for multilingual sites?

    Hey, https://www.youtube.com/watch?v=dakxwoVV7yM

    😉

    #1421258

    Rad
    Moderator

    Hi there,

    That string is already translatable, you can find it on this file

    \wp-content\plugins\x-email-mailchimp\email-integration\functions\shortcodes\subscribe.php

    with textdomain of __x__

    if ( is_wp_error( $result ) ) {
          $response = array(
            'error'       => true,
            'log_message' => $result->get_error_message(),
            'message'     => __( 'We\'re sorry! Something went wrong. We were unable to add your email to the list. Please try again later.', '__x__' )
          );
        }

    And you can’t add textdomain declaration within gettext filter, because gettext itself is the function responsible for translation and textdomain, hence, it’s like calling itself and that will cause loop issue.

    What I’m not sure is why your WPML isn’t able to find it, probably settings related. Have you translated your plugins using MO/PO files? Because WPML also relies on those files.

    Thanks!

    #1421803

    Meng
    Participant

    Hi Rad,

    Thanks for diving a bit deeper. Thanks to your info, I’ve been able to track the issue. As it turns out, the translation has to be attached to the original text string:

    
    'We\'re sorry! Something went wrong. We were unable to add your email to the list. Please try again later.', '__x__'
    

    Whereas the English version has already been altered thanks to this code snippet:

    
    add_filter('gettext', 'reword_mailchimp_error_message', 20, 3);
    function reword_mailchimp_error_message ( $translated, $text, $domain ) {
      return $text == 'We\'re sorry! Something went wrong. We were unable to add your email to the list. Please try again later.' ? 'YOUR NEW WORDING HERE' : $translated;
    }
    

    What confuses me is how the new translation (YOUR NEW WORDING HERE) does not get tracked in WPML String Translation. Because of this, the translation will hook on correctly and the English version is still shown on other language pages too…