View Categories

Multilingual Emails with [translate]

If you sell in more than one language, a single custom email can carry every language at once. Additional Custom Emails & Recipients for WooCommerce provides a [translate] shortcode that outputs different text depending on the order’s or the current user’s language, and a per-email condition that restricts an email to specific languages. Both work with WPML, Polylang, and TranslatePress.

The [translate] shortcode works in the Subject, Email heading, and Email content fields, configured per email under WooCommerce > Settings > Emails.

How the language is detected #

When the email is for an order, the plugin reads the language stored on that order, in this order of preference:

  1. WPML order language (the wpml_languages or wpml_language order meta).
  2. Polylang order language (the order’s language term).
  3. TranslatePress order language (the trp_language order meta).

If there is no order, or none of those are present, the plugin falls back to the current site language: WPML’s or Polylang’s ICL_LANGUAGE_CODE, then TranslatePress’s active language. If nothing resolves, there is no current language and every “other languages” branch is used.

Because the order’s own language is read first, a customer who checked out in German receives the German branch even if an admin later re-sends the email from a different language context.

The three forms #

Language codes are matched case-insensitively, and any lang or not_lang attribute accepts a comma-separated list.

1. Attribute form #

No enclosed content. Supply the matching text and the fallback text as attributes. Use this for short strings such as a subject line.

[translate lang="EN,DE" lang_text="Your order" not_lang_text="Votre commande"]

If the current language is EN or DE, “Your order” is output; otherwise “Votre commande”.

2. Inclusion form (enclosing) #

The enclosed content is shown only when the language is in the lang list, and suppressed otherwise.

[translate lang="EN,DE"]Thank you for your order![/translate]

3. Exclusion form (enclosing) #

The enclosed content is shown for every language except those in the not_lang list.

[translate not_lang="EN,DE"]Merci pour votre commande ![/translate]

Putting it together #

Chain the inclusion and exclusion forms to cover all your languages in one block. Keep the shortcodes on one continuous line with no line breaks between them, because each non-matching branch resolves to an empty string and stray line breaks would survive into the sent email:

[translate lang="EN"]Thank you for your order, [order_billing_first_name]![/translate][translate lang="DE"]Vielen Dank fur Ihre Bestellung, [order_billing_first_name]![/translate][translate not_lang="EN,DE"]Merci pour votre commande, [order_billing_first_name] ![/translate]

Shortcodes placed inside the enclosed content are processed after the matching branch is chosen, so [order_billing_first_name] above is filled in normally in whichever branch is shown.

Restricting an email to specific languages #

Sometimes you do not want to translate one email but to send an entirely separate email per language. Every custom email has a WPML/Polylang language condition (option ID required_wpml_languages) in its Email Data section. It only appears when a multilingual plugin reports active languages.

Option Option ID Effect
WPML/Polylang language required_wpml_languages Select one or more languages. The email is sent only when the order’s resolved language is one of them.

Leave it empty to send in every language. Set it to, say, German only, and duplicate the email in Pro for each other language, to run a fully separate template per language.

Notes #

  • The [translate] shortcode reads the language and switches text; the required_wpml_languages condition decides whether the email sends at all. They are independent and can be used together.
  • For the enclosing forms, a language matches when its code appears in the comma-separated list. Codes are compared in lower case, so EN, en, and En behave the same.
  • TranslatePress is supported for reading the order and current language, so [translate] works there as well as with WPML and Polylang.

Reach every customer in their language #

Additional Custom Emails & Recipients for WooCommerce keeps your multilingual notifications in one place. Get the plugin to translate your store’s emails without maintaining a separate plugin for it.