Hi, we have noticed while we are trying to translate the two different emails reset_email and passowordless connection that they behave differently when it comes to what kind of available attributes we can use with the liquid syntax.
Like for instance, when customizing the passwordless email template, we have access to a tag called request_language
(e.g en,nb;q=0.9,no;q=0.8,en-US;q=0.7,en-GB;q=0.6,nn;q=0.5
) which is equal to the Accept-Language header user’s is requesting when clicking the reset password link. But when we are triggering the password reset flow we won’t get access to the same attribute when translating. This inconsistency makes it harder to create a default experience where we can use the user’s prioritized languages in the browser.
We are familiar that we can store the locale in user_metadata and use it when translating, but that also requires us to sync the locale to auth0 before we send an email asking them to the reset the password, or log in using google or linkedin.
The most ideal situation for us is that we could have used both approaches
- User ask for reset password. User does not exist in auth0 and we don’t have the locale → use the browser locale
- When the user logs in. Use a action on the login flow to update the locale in user_metadata
- The second reset of password will then use the locale in user_metadata
Same goes for the passwordless flow where we are not able to set the user_metadata during the login flow, but as long as we do have access to both user_metadata and the request_language we are able to fallback to sane default that makes sense for the user
Is this a bug or a feature that we don’t have access to request_language
in reset_emails? Do we have the same issue with all of the other email templates as well?
For the curious we extract the locale from request_language using the following liquid snippet in the passwordless email
{%- assign languages = request_language | split: "," -%}
{%- assign selectedLocale = 'nb' -%}
{%- for lang in languages -%}
{%- assign locale = lang | slice: 0,2 -%}
{%- if locale == 'nb' or locale == 'no' or locale == 'nn' -%}
{%- assign selectedLocale = "nb" -%}
{%- break -%}
{%- elsif locale == 'sv' -%}
{%- assign selectedLocale = 'sv' -%}
{%- break -%}
{%- endif -%}
{%- endfor -%}
{{ selectedLocale }}