Customizing a Single Email Template for Multiple Languages
This article provides instructions for using conditional logic to support multiple languages within a single email template.
- Universal Login
- Email Templates
- Email Localization
The only method to support multiple languages in a single email template is to use if/else conditional statements with Liquid syntax.
-
Define and store a user's language preference in a variable that is accessible by the email template. For example, use an Auth0 Action to set
user.user_metadata.langto the user's preferred language. -
Use conditional Liquid syntax in the email template to display different content blocks based on the language preference variable.
{% if user.user_metadata.lang == 'es' %}
Hola {{ user.name }}, ...
{% elsif user.user_metadata.lang == 'ru' %}
Ciao {{ user.name }}, ...
{% else %}
Hi {{ user.name }}, ...
{% endif %}
For an example of customizing the email subject of the Change Password Email Template based on the language specified in the user metadata, review the following video: