Hello,
following the Auth0 quickstart I created a react spa that uses Auth0, everything work fine, but I did not find any doc explaining how to change language in the login popup, at least not for the React SPA component I am using (Auth0Provider).
Any hint on how to achieve that?
To provide more detail below is the link to an issue I created on the quickstart sample I used as template, there you can find more details and screen captures
Thanks
Do you want to set the language to a fixed language (for all users), or shall it depends on something from the userâs context, such as browser/user agent language?
Also, are you using the New ULP or the Classic ULP (ULP = Universal Login Page)?
Because if youâre using the New ULP, then see
Note that the Accept-Language header sent by the userâs browser takes a higher priority than the default language you set in the tenant settings globally.
Therefore, in order to enforce a specific language in the New ULP, you should add the ui_locales parameter to the authorize request, like:
Even if you set a default language in the tenant settings, the request header Accept-Language of the userâs browser takes a higher priority, which in my case is en.
So, the way to enforce it is to add this to the authorize request when making the authorization request:
webAuth.authorize({
ui_locales: 'de'
});
In case youâre using the Classic ULP, I recommend to also use the ui_locales parameter as mentioned above, then customize the login page and add this in the code:
language = config.extraParams.ui_locales;
In the default Lock template, that would be around line 36. Without it, the Accept-Language header will otherwise take precedence.
Please note my question is specific to Reactdevelopment .
I should add that I have included the additional languages Iâd like to use in my tenant settings in the dashboard.
I already saw the articles you linked but the problem is they refer to JavaScript libraries and SDKs, I am using a React SPA following the article in your docs at:
I am using this React component with these parameters:
I donât have access to the underlying JavaScript functions. I guess the React components I am using choose the classic login by default, but thatâs fine for now, I just want to be in control of the language Auth0 uses for the popups.
Should I add the language to loginWithRedirect({}) which is currently with empty parameters? What is the syntax? I couldnât find doc reference not source on github for this function.
Or is there any way to set the language in the Auth0Provider props?
The language must be used only for the current user and must override any other setting in the browser or anything else. For example, if a German user want to use the app in French or Spanish for whatever reason, he must be able to do so by choosing âFRâ or âESâ in the app top navbar.
I will test it myself, but can you confirm that if you use the Classic ULP and not New ULP, you also did the change in the Auth0 login page itself via customization, as mentioned above?
In case youâre using the Classic ULP , I recommend to also use the ui_locales parameter as mentioned above, then customize the login page and add this in the code:
language = config.extraParams.ui_locales;
In the default Lock template, that would be around line 36. Without it, the Accept-Language header will otherwise take precedence.
IT WORKS!!!
You are the man!
Thank you
I guess the additional line of code in the custom login was not saved.
The first time worked only in Spanish, Italian caused internal error, after refreshing worked fine also in Italian.