Auth0 Home Blog Docs

.net core lock language

lock
aspnet-core

#1

Hi, can anyone know how i can change lock language with .net core?

Thank you


#2

The Lock language can be changed in the options object passed during Lock instantiation:

// Select a supported language
var options = {
  language: 'es'
};

// Initiating our Auth0Lock
var lock = new Auth0Lock(
  'CLIENT_ID',
  'TENANT.auth0.com',
  options
);

https://auth0.com/docs/libraries/lock/v10/i18n


#3

I don’t have this code, here is my .net core login screen init code:

public IActionResult Login()
        {
            return new ChallengeResult("Auth0", new AuthenticationProperties() { RedirectUri = "/" });
        }

#4

I’m seeking for an answer to this as well. Would be nice if properties added to the Items dictionary could be encoded in the url if a certain prefix is used, e.g. auth0_lang would be added to the uri &lang=sv and then available in config.lang.


#5

@charettedavid Here is the solution

OnRedirectToIdentityProvider = context =>
{
// More dynamic approach would be using request context
var requestCulture = context.Request.HttpContext.Features.Get<IRequestCultureFeature>();
                        var code = requestCulture.RequestCulture.UICulture.TwoLetterISOLanguageName;
                        context.ProtocolMessage.SetParameter("lang", code);
// Here you can set additional parameters that will be appended to the query string and hence available in lock
return Task.CompletedTask;
}

You might need to parse the query strings in script section of login page the extract values if they are not default Auth0 config settings


#6

Thank youi! very appreciated. Hope they will update the documentation.


#7

Working, but param is : lang
context.ProtocolMessage.SetParameter(“lang”, “fr”);


#8

Thanks for this. I have made a note that we get these additional parameters properly documented


#9

Is there any link on how to migrate to ASP.NET Core 2.0? The authetication modules have changed quite a bit!

Great job


#10

I used the info over here to migrate our own samples:
https://github.com/aspnet/Announcements/issues/262


#11

You can also review the V2 branch of our samples repo:
https://github.com/auth0-samples/auth0-aspnetcore-mvc-samples/tree/v2


#12

I don’t have this code, here is my .net core login screen init code:

public IActionResult Login()
        {
            return new ChallengeResult("Auth0", new AuthenticationProperties() { RedirectUri = "/" });
        }

#13

I’m seeking for an answer to this as well. Would be nice if properties added to the Items dictionary could be encoded in the url if a certain prefix is used, e.g. auth0_lang would be added to the uri &lang=sv and then available in config.lang.


#14

Thank youi! very appreciated. Hope they will update the documentation.


#15