• Resolved alexprs7

    (@alexprs7)


    Hello,

    I want to send automatic purchase confirmation emails (WooCommerce), newsletters as well as invoices in the customer’s language when (the customer changes language thanks to the “switcher” button with the flag which is on my internet site)

    How to do it please.

    Thank you

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello,

    The WooCommerce emails are actual templates (like theme files) so it means you can translate whatever is localized using gettext in them. https://codex.www.ads-software.com/Plugin_API/Filter_Reference/gettext

    Our plugin doesn’t yet detect these strings because they are not visible in the front-end, only processed. The good news is that most languages already have these translated properly.

    Alternatively, you can also use LocoTranslate in order to translate these strings https://www.ads-software.com/plugins/loco-translate/.

    A side note to take into account: while emails that get sent after a user action are translated correctly, out of order emails like reminders (if you use subscriptions) will always be sent in the default language as we don’t store the user language in order to know in what language we should send the email.

    The most recommended way is to translate those strings via Google Translation API.
    (Add a Google Translation API key into your website, send some dummy test emails and the API will translate them (if that custom language is on Google language list)
    If not, you can translate each string from the database directly.
    For this we have a small video showing the steps:
    https://www.berrycast.com/conversations/26e8b9cf-8334-5ef5-b248-4f2d57cbcb64

    Kind regards,
    Kind regards,

    Hi!

    A side note to take into account: while emails that get sent after a user action are translated correctly, out of order emails like reminders (if you use subscriptions) will always be sent in the default language as we don’t store the user language in order to know in what language we should send the email.

    There is actually a solution for that:
    https://gist.github.com/dartrax/85b3ab77b8210e92cc50e1b68de83c73

    With this additional code, the user language will be stored in the order metadata and the “out of order” emails will be sent in the correct language.

    – dartrax

    Thread Starter alexprs7

    (@alexprs7)

    How do you translate emails into another language if you do?
    I need help

    Hi @alexprs7
    I use this code:
    https://gist.github.com/dartrax/85b3ab77b8210e92cc50e1b68de83c73

    With this additional code, the user language will be stored in the order metadata and the “out of order” emails will be sent in the correct language.

    The definition of the translation is done via the ‘normal’ WordPress translation with .mo/.po-files. If you did not change the default settings or template for Mails, the translations are already there for you. There are only small pieces left, where the strings are set in the admin settings, like the “Additional content” setting. Here, you need to work with the conditional shortcode, for example:

    [trp_language language="de_DE_formal"]
    Danke fürs Lesen.
    [/trp_language][trp_language language="en_US"]
    Thanks for reading.
    [/trp_language]
    Thread Starter alexprs7

    (@alexprs7)

    Hi @dartrax
    Thanks for your reply, should i save your code in functions.php file ?

    Hi @alexprs7 ,
    only the code from the Github gist goes to the functions.php.

    The code that I posted in my recent reply to you (with the conditional shortcode [trp_language language=”…”]) goes into the mail settings in the admin area. For example, in the ?additional content“ value of the mail settings.

    Please let me know if you don‘t know where/what I mean, I can post a screenshot in a few days as I‘m on holiday and away from a pc right now.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to send WooCommerce emails in the customer’s language’ is closed to new replies.