Auth0 Home Blog Docs

How to set the language in Lock using universal Login


#1

I’m using universal login with Lock in a React application. I’m following help pages on internacionalization but don’t see how I can send the language option to the Lock widget.

Here https://auth0.com/docs/libraries/lock/v11/i18n it says you can pass an options object to the Lock constructor, but I’m not calling the constructor by myself. In universal login you just call auth0.authorize() method.

How do you pass this option so the Lock widget is displayed in the user language?

Lock widget does not pick the browser language either which will serve my needs.


#3

Hey @david.casillas!

That is correct. Lock doesn’t pick the browser language itself. Universal Login itself uses Lock and by customizing it, you can use language-parameter to a certain extend.

You need to do it by initializing options variable where you’ll specify the language and then once instantiating Lock, you’ll pass it as a parameter.


#4

Hi thanks, but can you be more clear on where and how to?

You need to do it by initializing options variable where you’ll specify the language and then once instantiating Lock, you’ll pass it as a parameter

Right now I’m just invoking the login widget with:

auth0.authorize();

With auth0 being an auth0.WebAuth instance with this params:

  auth0 = new auth0.WebAuth({
    domain: 'xxxxxx',
    audience: 'xxxxxx',
    clientID: 'xxxxxx',
    redirectUri: 'xxxxxx',
    responseType: 'token id_token',
    scope: 'openid profile email'
  });

Can I pass some options to the authorize() call or to the WebAuth constructor with the language? I have tried but didn’t work.