Emails are not sent in the correct language
-
Hello, the site is built with elementor pro, woocommerce and two languages are set with translatepress. The translation for emails appear correctly in Translatepress string translation, we use the woocommerce standard emails (no changes have been made), but when a customer orders in second language, all the emails (also the first email) are sent in the default language and not the second language. How could we solve to send the email correctly?
-
Hello,
Thank you for reaching out. TranslatePress has built-in integration with WooCommerce for email translation, ensuring that the emails are sent in the language preferred by the users. Here’s a bit more detail on how this works:
For the customer emails, they are sent in the language that the customer last browsed your website in. If they are logged-in users, this is updated automatically based on their last visited language. If they aren’t required to log in before placing an order, the language used when placing the order will be used for all subsequent email notifications.
Regarding admin/shop manager emails, these are sent in the recipient’s preferred language, not in the customer’s language. This preferred language is based on the language set in their WordPress dashboard, which can be changed by navigating to Users → Profile → Language.
If you configure the email recipient to a different email address in WooCommerce → Settings → Emails, then the language set for that user will be used. If multiple recipients are set for a particular email type, the email will be sent in the TranslatePress Default Language.
For translating email content, all default texts found in WooCommerce emails are translated using plugin-localized texts or through Automatic Translation, if enabled. User-inputted text, like those used when customizing WooCommerce Emails, will also be translated using Automatic Translation if enabled. TranslatePress has a “Emails” tab in the Translation Editor->String Translation where you can manually edit the translation of the emails.
This requires TranslatePress – Multilingual version 2.3.5+ and WooCommerce version 6.8+.
However, if you’ve already set this up correctly and the emails are still being sent in the wrong language, there may be a compatibility issue with your setup. If that’s the case, we recommend performing a compatibility test to identify any conflicts.
Lastly, could you please confirm if you have translated the emails in the first place?
Best Regards,
Hello, thank you for your answer. All is set up correctly as you mentioned, but not working. I will try to perform again a compatibility test. The emails appear translated in the string translation – emails section. The standard woocommerce emails haven’t been modified. There is no login for customers, customers navigate the site in the language selected from the menu. Customers should receive their email based on this language and not the website’s default language.
I performed the compatibility test and I found no conflict. I observed that actually this is happening: when the customer makes the order in the second language, the thank you page throws back to the default language and therefore also emails are sent in the default language. If I change again the country flag on the thank you page, then it displays in the correct language (the second). In the Translatepress settings Force language custom links is enabled. I tried also to disable it, but I get the same result in both cases. How could I assure that the thank you page doesn’t throw back to default language if second language is chosen? I guess emails will also display correctly if this issue with the thank you page is solved.
Update: I rolled back the Translatepress version from 2.5.6 to 2.4.1, and with this previous version the emails are sent correctly. WordPress, woocommerce, elementor, elementor pro are the latest versions.
We need to take the pulse of this ticket. Is there still an issue?
In the meantime, I set this ticket as Resolved. You can also change its status back to unresolved and let us know by replying to this topic if your request still needs attention.
Another option is to leave this ticket as it is and open a new one where to mention the issue again and ask for support.It is still an issue.
Version 2.7.1 and still is happening.
@rygoria
Translating WooCommerce emails in the preferred user’s language is entirely supported by TranslatePress, but if you are looking to provide support for another plugin/theme, or you have an addon from Woo that sends these emails, you can use our documentation: https://translatepress.com/docs/send-emails-in-users-preferred-language/- This reply was modified 9 months, 1 week ago by Alex.
Hi, same problem here but with Paid Member Subscriptions, all the mails send in core language.
Still same. It redirects clients to order-received page in default language and send default email.
We offer support for base WooCommerce emails. Everything that comes from a 3’rd side may not work properly.
If it’s apply for WooCommerce base emails, please write us on our website, https://translatepress.com/support/ask-a-presale-question/,and mention the link to this thread as well. We may need to investigate the case in detail.My 3rd party fix: TranslatePress needs to collect/store the order-id before the trigger is called to send an email. This order-id is used to fetch the user-id, to get the user language (user_meta: ‘trp_language’), else order language. TRP collects the order-id by monitoring the order_status. There are multiple actions (TRP has about 17 actions declared) on change of order status like this:
add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'store_email_order_id' ), 5, 1 );
When an email is sent by an email object, the function ‘trigger’ is called. It should first calls
$this->setup_locale()
and ends with$this->restore_locale()
. TRP hijacks the filters (as they call it in their notes) within these functions to do the switching of the language.My solution was finding the last possible action to collect the order-id before the custom email in the third party woocommerce plugin was sent. If you find that you can save the order-id in the global variable
$TRP_EMAIL_ORDER
TRP uses to store it in. The plugin I use was saving order meta before sending email. My solution:add_action( 'updated_order_meta', 'name_of_my_function', 10, 3);
function name_of_my_function( $meta_id , $order_id , $meta_key ){
if( $meta_key === '_name_of_order_meta_key' ){
global $TRP_EMAIL_ORDER;
$TRP_EMAIL_ORDER = $order_id;
}
}Additional, TRP has a filter to set the language for woocommerce emails:
apply_filters( 'trp_woo_email_language', $language, $is_customer_email, $recipients, $user_id )
- You must be logged in to reply to this topic.