How to detect language in the Email Template, such as for "Change Password"?

My site is using Auth0’s Lock UI to handle Logins and Password Reset Requests.

At the Lock UI, it is multilingual, with the JavaScript “options.language” being either “en” or “fr”.

In the Auth0 Admin Panel’s “Emails” -> “Templates” -> “Change Password”, is there a variable/macro that represents the language from the Lock UI that had triggered that Email Template?

What I want to do is something like this in the Email Template:

{% if lang == ‘fr’ %}Bonjour{% else %}Hello{% endif %}

So if the user was using Lock in French, then the Password Reset Email will be in French, and if they then changed it to English, then triggering the Password Reset Email would send off an English email instead.

The user.user_metadata contain the user locale.

{% if user.user_metadata.locale == 'fr' %}
  Bienvenue au ...., {{ }}
{% elsif user.user_metadata.locale == 'it' %}
  Benvenuti nel ..., {{ }}
{% elsif user.user_metadata.locale == 'es' %}
  Bienvenido a ..., {{ }}
{% elsif user.user_metadata.locale == 'pl' %}
  Witaj w ... {{ }}
{% else %}
  Welcome to ..., {{ }}
{% endif %}

Thanks for the reply, but I do not have the locale stored in the user metadata.

I want to obtain the locale that was set in “Lock” in the JavaScript.


Any updates on this?

Hey there @vivek!

Unfortunately it’s not doable for now to get the value from Lock. You can do it the way @andrelacasse suggested. For the first one I suggest submitting a feature request through our product feedback site providing all the context to the usecase:

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.