# Localize email verification message

**URL:** <https://community.auth0.com/t/localize-email-verification-message/56510>\
**Category:** Get Help\
**Tags:** email-template, email-verification, auth0\
**Created:** [January 20, 2021, 1:38pm UTC](https://community.auth0.com/t/localize-email-verification-message/56510 "2021-01-20T13:38:37Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomrozb](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tomrozb/32/27023_2.png) [@tomrozb](https://community.auth0.com/u/tomrozb)\
**Post date:** [January 20, 2021, 1:38pm UTC](https://community.auth0.com/t/localize-email-verification-message/56510/1 "2021-01-20T13:38:37Z")

</div>

According to documentation it’s possible to localize email verification message sent to the newly registered users. Due to the bug reported here [Access user language user\_metadata.lang in email template](https://community.auth0.com/t/access-user-language-user-metadata-lang-in-email-template/44932) the language value is empty.

Is there any progress on this? Is there any workaround?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [January 21, 2021, 5:46pm UTC](https://community.auth0.com/t/localize-email-verification-message/56510/3 "2021-01-21T17:46:40Z")

</div>

Hi @tomrozb,

Welcome to the Community!

I’m not actually sure this is a bug, but rather a confusing doc. This is saying you could use a variable stored in user\_metadata to configure language, not that there is one stored automatically. [Here is the doc](https://auth0.com/docs/architecture-scenarios/implementation/b2c/b2c-profile-mgmt?_ga=2.125686345.2114283684.1611076856-1261373470.1602622721#user-metadata) that states that you _could_ store language preference in user\_metadata.

This obviously isn’t clear and I will put a request in to update the doc.

As far as a solution goes, how do you want to determine language? From the Accept-Language header, or from user-selected input in your app or login page?

---

<div class="post-metadata">

**Author:** ![tomrozb](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tomrozb/32/27023_2.png) [@tomrozb](https://community.auth0.com/u/tomrozb)\
**Post date:** [January 21, 2021, 6:00pm UTC](https://community.auth0.com/t/localize-email-verification-message/56510/4 "2021-01-21T18:00:05Z")

</div>

Hey Dan, thanks for looking into it.

The language code is passed as a `ui_locales` parameter to login page, so the login page is properly localized (the “new” one).

I assume there should be a way to get back this parameter in email templates, but I didn’t find a way to achieve this.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [January 22, 2021, 12:41am UTC](https://community.auth0.com/t/localize-email-verification-message/56510/5 "2021-01-22T00:41:28Z")

</div>

I was able to set up a rule that grabs the ui\_locales and sets it as the user\_metadat.lang, but at this point in the pipeline the email template has already used the older user\_metadata object with no language, so it won’t affect any emails going out on the first login cycle.

Are you users database users? Or do you have social/enterprise users as well?

I am going to post the rule as it could help for other emails (like password reset).

```auto
function(user, context, callback){
  // set metadata object
  user.user_metadata = user.user_metadata || {};
  
  // if lang exists for the user, skip rule
  if(user.user_metadata.lang){
    callback(null, user, context);
  }

  // set language variable to ui_locales or default to 'en'
  let preferedLanguage = context.request.query.ui_locales || 'en';

  // update the user_metadata that will be part of the response
  user.user_metadata.lang = preferedLanguage;

  // persist the user_metadata update
  auth0.users.updateUserMetadata(user.user_id, user.user_metadata)
    .then(function(){
      callback(null, user, context);
    })
    .catch(function(err){
      callback(err);
    });
}

```

---

<div class="post-metadata">

**Author:** ![tomrozb](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tomrozb/32/27023_2.png) [@tomrozb](https://community.auth0.com/u/tomrozb)\
**Post date:** [January 24, 2021, 9:11am UTC](https://community.auth0.com/t/localize-email-verification-message/56510/6 "2021-01-24T09:11:58Z")

</div>

This actually works indeed for the 2nd and subsequent mails sent, that’s a progress 🙂

Is there some other way to localize the first verification email sent to users? Seems that’s the missing piece to implement full localization of emails.

Thank you Dan!

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [January 25, 2021, 5:22pm UTC](https://community.auth0.com/t/localize-email-verification-message/56510/7 "2021-01-25T17:22:38Z")

</div>

I can reach out to some folks to see if there is a workaround for this. I’ll report back here with my findings.

EDIT: before I do that, can you answer this question from my previous post:

> Are you users database users? Or do you have social/enterprise users as well?

---

<div class="post-metadata">

**Author:** ![tomrozb](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tomrozb/32/27023_2.png) [@tomrozb](https://community.auth0.com/u/tomrozb)\
**Post date:** [January 26, 2021, 12:32pm UTC](https://community.auth0.com/t/localize-email-verification-message/56510/8 "2021-01-26T12:32:22Z")

</div>

Users database + social (fb, apple, google). Does that change anything?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [January 26, 2021, 4:55pm UTC](https://community.auth0.com/t/localize-email-verification-message/56510/9 "2021-01-26T16:55:54Z")

</div>

If you were only using DB users you could get away with doing this in a hook. Sounds like that isn’t the case, so you will need another solution. Let me look into it further and I will report back.

---

<div class="post-metadata">

**Author:** ![tomrozb](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tomrozb/32/27023_2.png) [@tomrozb](https://community.auth0.com/u/tomrozb)\
**Post date:** [January 26, 2021, 5:13pm UTC](https://community.auth0.com/t/localize-email-verification-message/56510/10 "2021-01-26T17:13:52Z")

</div>

But as far as I understand the verification email is sent only to users who sign up with their email. There’s no verification email for apple/google/fb.

Could you please share the solution with a hook?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [January 26, 2021, 5:59pm UTC](https://community.auth0.com/t/localize-email-verification-message/56510/11 "2021-01-26T17:59:27Z")

</div>

Sure, you will want to create a pre-registration hook like this:

```auto
/**
@param {object} user - The user being created
@param {string} user.tenant - Auth0 tenant name
@param {string} user.username - user name
@param {string} user.password - user's password
@param {string} user.email - email
@param {boolean} user.emailVerified - is e-mail verified?
@param {string} user.phoneNumber - phone number
@param {boolean} user.phoneNumberVerified - is phone number verified?
@param {object} context - Auth0 connection and other context info
@param {string} context.renderlanguage - language used by signup flow
@param {string} context.request.ip - ip address
@param {string} context.request.language - language of the client agent
@param {object} context.connection - information about the Auth0 connection
@param {object} context.connection.id - connection id
@param {object} context.connection.name - connection name
@param {object} context.connection.tenant - connection tenant
@param {object} context.webtask - webtask context
@param {function} cb - function (error, response)
*/
module.exports = function (user, context, cb) {
  var response = {};
  response.user = user;
  response.user.user_metadata = { lang: context.renderLanguage };
  cb(null, response);
};

```

The ui\_locales param isn’t available directly in the hook. Instead, we use the renderLanguage of the login page. Whatever language the Universal Login page is rendered in will be set as user\_metadata.lang.

---

<div class="post-metadata">

**Author:** ![tomrozb](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tomrozb/32/27023_2.png) [@tomrozb](https://community.auth0.com/u/tomrozb)\
**Post date:** [February 10, 2021, 8:50am UTC](https://community.auth0.com/t/localize-email-verification-message/56510/12 "2021-02-10T08:50:00Z")

</div>

That’s perfect!

BTW is there a way to localize the webpage displayed after the e-mail address is confirmed? I mean the “Your email address was successfully verified” message? I’ve not found settings for this in web console.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [February 10, 2021, 10:14pm UTC](https://community.auth0.com/t/localize-email-verification-message/56510/13 "2021-02-10T22:14:21Z")

</div>

I can’t find a way to do it. Let me reach out to the team.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [February 10, 2021, 10:22pm UTC](https://community.auth0.com/t/localize-email-verification-message/56510/14 "2021-02-10T22:22:09Z")

</div>

Actually, before I do that. How are you creating users? I am redirected directly to my app, I don’t see the verification page.

---

<div class="post-metadata">

**Author:** ![tomrozb](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tomrozb/32/27023_2.png) [@tomrozb](https://community.auth0.com/u/tomrozb)\
**Post date:** [February 11, 2021, 8:57am UTC](https://community.auth0.com/t/localize-email-verification-message/56510/15 "2021-02-11T08:57:57Z")

</div>

The webpage is displayed once the email confirmation link is clicked on a computer (not in a mobile browser)

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [February 11, 2021, 8:34pm UTC](https://community.auth0.com/t/localize-email-verification-message/56510/16 "2021-02-11T20:34:34Z")

</div>

Okay great. I reached out to the team on it.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [February 11, 2021, 9:38pm UTC](https://community.auth0.com/t/localize-email-verification-message/56510/17 "2021-02-11T21:38:20Z")

</div>

Okay, we figured it out. You need to append a `ui_locales` param to the verification URL you set in the email template.

The email verification URL you have access to in the template has a fragment (#) at the end so you have to do some string manipulation to remove it.

Here is how I did it.

```auto
{% assign splitURL = url | split: '#' %}
{% assign languageURL = splitURL[0] | append: '&ui_locales=' | append: user.user_metadata.lang %}
<p><a href="{{ languageURL }}">Confirm my account</a></p>

```

The URL should look something like this:  
`https://example.auth0.com/u/email-verification?ticket=123456786897qwerwuiyoiu&ui_locales=es`

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [February 26, 2021, 11:23pm UTC](https://community.auth0.com/t/localize-email-verification-message/56510/19 "2021-02-26T23:23:50Z")

</div>

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