question

lbartolic avatar image
0 Votes"
lbartolic asked lbartolic edited

How to read both locale and country consistently using Azure B2C Custom Page with JavaScript?

Azure B2C provides a way to define custom page layouts and make use of JavaScript for various reasons. One of these is detecting user's locale and country. Using window.SETTINGS object, we can read a lot of settings exposed by B2C, and one of the objects is locale.

One of our requirements is to be able to detect user's language and country based on the preferences (either by providing ui_locales as the part of the URL or based on the browser's settings). However, we are having issues in getting window.SETTINGS.locale values consistently.
For an example:
- when ui_locales with the value of it-CH is passed, locale object returns {lang: 'it', country: 'CH'}
- when ui_locales value is not passed through the URL, but the user has Italian (Switzerland) selected as the preferred locale and country (through the browser settings), then locale object returns {lang: 'it'}

In the second case, even the country is provided and exposed by the browser, B2C does not make it available through window.SETTINGS.locale.

Is there a way to read these settings consistently using one single method so that both lang and country can be retrieved in case those are present either through ui_locales or browser settings?

Thanks!

azure-ad-b2c
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers