HTML Email Templates in multi language.

My site is multi-language. I want to email to follow the same. I would like that it sends only the language which is selected on the site. For example when you use the German language on the site then It sends the German version of the mail. Is there is any hook, filter or workaround that I can use?

  • Lindeni Mahlalela

    Hello Hazem Tasmem

    I hope you are doing great today and thank you for contacting us regarding your needs.

    I have looked into this and noticed I have found that the HTML Email Templates plugin only sends emails based on the content it is given it doe not have any hooks to modify the content, it only provides a layout for presenting the email to the recipient. I have tested this by changing the Site Language in WordPress admin "Settings > General", once I have set to any language, I have created a test user and I received the notification in the language I specified for Site Language in the settings. This means the emails are translated in the WordPress Core, Plugins, Theme or by using a translations plugin like WPML in "WPML>String Translation".

    A big factor here is the source of the content, this could be a plugin's notification settings or a post sent out as a newsletter. In all cases, the content must be translated before being passed to HTML Email Templates which will only give it a new look based on the template specified for the website.

    I have noticed that in one of the website with support access, the website uses WPML, that means you can translate strings from "WPML > String Translations" then from there you can translate the strings for the plugins/theme. That way if the plugin is sending out notifications they will be received in that language being viewed in the front end or based on the Site Language specified in the settings.

    If you are sending out newsletters then you need to translate the newsletters themselves. If you are sending out posts on your website then those posts can be translated using the translation plugin, even some plugins that use the WP Editor makes it easier to translate the content since most translation plugins use the WP Editor for translation.

    Since I noticed that you are using WPML on one of your websites then refer to the following documents and see what needs to be done to get this to work:

    Sending emails with wpml: https://wpml.org/documentation/support/sending-emails-with-wpml/
    How a third party plugin did it: https://wpml.org/2016/06/try-sensei-plugin-wpml-mail-api-integration/
    Translating notification emails. This was a question for translating WooCommerce order emails but I believe the same information will apply to other plugins as well: https://wpml.org/forums/topic/translating-the-admin-new-order-email/

    The bottom line here is that the content is sent out as is by the HTML Email Templates plugin and it has to be translated before it can be sent. It can be translated in the WordPress Core, Plugin, Theme or Post Content whichever the source of the email is. Good news is that if a plugin or theme is not translated for the specific language then you can translate it in "WPML > String Translation" page. Once that is done, WPML will send the relevant translation based on the language being viewed on the site.

    I hope this helps. Please let us know if we missed something or if you need help with anything else regarding this.

    Have a nice day.
    Mahlamusa

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.