Tagged: x
-
AuthorPosts
-
September 27, 2016 at 11:56 pm #1193397
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!
September 28, 2016 at 4:25 am #1193602Hey 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.
September 28, 2016 at 9:49 am #1194020Hi 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!
September 28, 2016 at 11:01 am #1194132Hi 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 CredentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
Thanks
Joao
November 29, 2016 at 10:21 am #1274799Hello, 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!
EmmaNovember 29, 2016 at 10:51 am #1274841Hi 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.
November 30, 2016 at 3:51 pm #1276588Thank you – that worked perfectly!
EmmaNovember 30, 2016 at 3:53 pm #1276595Glad we could help 🙂
Cheers!
March 19, 2017 at 5:02 pm #1412960Hey 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…
March 20, 2017 at 3:20 am #1413331Hi there,
Which string and how it’s implemented? Would you mind providing some details and screenshots?
Thanks!
March 20, 2017 at 3:26 pm #1414149I 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.
March 21, 2017 at 5:05 am #1414731That 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.
March 26, 2017 at 10:00 pm #1421121Why? 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
😉
March 27, 2017 at 1:52 am #1421258Hi 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!
March 27, 2017 at 10:38 am #1421803Hi 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…
-
AuthorPosts