# Is there any way to get user language in auth0 rules?

**URL:** <https://community.auth0.com/t/is-there-any-way-to-get-user-language-in-auth0-rules/13708>\
**Category:** Get Help\
**Created:** [July 27, 2018, 12:34pm UTC](https://community.auth0.com/t/is-there-any-way-to-get-user-language-in-auth0-rules/13708 "2018-07-27T12:34:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jah](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jah/32/12805_2.png) [@jah](https://community.auth0.com/u/jah)\
**Post date:** [July 27, 2018, 12:34pm UTC](https://community.auth0.com/t/is-there-any-way-to-get-user-language-in-auth0-rules/13708/1 "2018-07-27T12:34:22Z")

</div>

I want to create a rule in auth0 that will add user’s language to user’s id token. So is there any way to achieve that? I can get country code and some other info from geoip but I can’t get language anywhere

---

<div class="post-metadata">

**Author:** ![kimcodes](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kimcodes/32/81052_2.png) [@kimcodes](https://community.auth0.com/u/kimcodes)\
**Post date:** [July 27, 2018, 2:40pm UTC](https://community.auth0.com/t/is-there-any-way-to-get-user-language-in-auth0-rules/13708/2 "2018-07-27T14:40:17Z")

</div>

👋 saw your question on SO Ill share it here in case others are looking for a way.

If you don’t already have the langauge you could collect the user’s language during the signup process by using the [`additionalsignupfields` option](https://auth0.com/docs/libraries/lock/v11/configuration#additionalsignupfields-array-) in Lock to show a drop-down of languages. The user would then select an option during sign up and the selected value can be persisted in `user_metadata`.

Alternatively, you can customize your login page using JavaScript to detect the user’s browser language, then auto-populate an additionalsignupfield in Lock with the value. We could even make this a hidden field if necessary.

Once stored in `user_metadata` we can then add that to the` id_token` something like:

```auto
function(user, context, callback) {

  // copy user metadata value in id token
  context.idToken['http://examplesite/user_lang'] = user.user_metadata.user_lang;

  callback(null, user, context);
} 

```

let me know if that is what you are looking to do.

---

<div class="post-metadata">

**Author:** ![oleg](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/oleg/32/15190_2.png) [@oleg](https://community.auth0.com/u/oleg)\
**Post date:** [May 2, 2019, 8:19pm UTC](https://community.auth0.com/t/is-there-any-way-to-get-user-language-in-auth0-rules/13708/4 "2019-05-02T20:19:53Z")

</div>

> [@kimcodes](#):
>
> Alternatively, you can customize your login page using JavaScript to detect the user’s browser language, then auto-populate an additionalsignupfield in Lock with the value. We could even make this a hidden field if necessary.

Hi @kimcodes! Could you please provide a sample code snippet for the `auto-populate an additionalsignupfield in Lock` part? ty!

---

<div class="post-metadata">

**Author:** ![kimcodes](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kimcodes/32/81052_2.png) [@kimcodes](https://community.auth0.com/u/kimcodes)\
**Post date:** [June 10, 2019, 7:42pm UTC](https://community.auth0.com/t/is-there-any-way-to-get-user-language-in-auth0-rules/13708/5 "2019-06-10T19:42:55Z")

</div>

@oleg were you able to get a code snippet to help you with your issue or did you still need that - if so I can take a look !

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [January 8, 2024, 9:28am UTC](https://community.auth0.com/t/is-there-any-way-to-get-user-language-in-auth0-rules/13708/6 "2024-01-08T09:28:09Z")

</div>

Hey there!

As this topic is related to Rules - Hooks - Actions and Rules & Hooks are being deprecated soon I’m excited to let you know about our next [Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team](https://community.auth0.com/t/auth0-community-ask-me-anything-rules-hooks-and-why-actions-matter/124043) on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

[Learn more here!](https://community.auth0.com/t/auth0-community-ask-me-anything-rules-hooks-and-why-actions-matter/124043)
