Customizing a Single Email Template for Multiple Languages

Overview

This article details how different languages can be used within a single email template.

Applies To

  • Email templates
  • Email localization
  • Email templates languages

Cause

An application may support multiple languages, such as English, Spanish, Portuguese, Chinese, Thai, and Vietnamese. The email template needs to be configured to support the desired language.

Solution

Currently, the only way to support multi-language emails is to have if/else conditional statements using Liquid syntax in the template for each language.

Below is the general approach:

  1. Create Separate Email Templates:

    Design separate email templates for each desired language (e.g., English, French, Spanish).

  2. Define and store a user’s Language preference which can be accessed in the email template:

    This can be set in an Auth0 Action. For example, user.user_metadata.lang is used to store the user’s preferred language.

    See this link for details regarding customized email templates, and check the Step 5 of the list located here.

  3. Conditional Content Blocks: Use Liquid’s if statements in the email template to display different content blocks based on the user.user_metadata.lang variable. For example:

    {% if user.user_metadata.lang == 'es' %}
    Hola {{ user.name }}, ...
    {% elsif user.user_metadata.lang == 'ru' %}
    Ciao {{ user.name }}, ...
    {% else %}
    Hi {{ user.name }}, ...
    {% endif %}
    

Related References