6

We have an Identity community which supports more than 50 languages built using visualforce pages. We would like to migrate the community to LWC. For that, main issue we are facing is the language support.

In vf page header we can add language attribute and based on this we can fetch the language from the labels and picklists. We want to do a similar thing. Is this supported in LWC.

Our login and registration page is in guest user mode. And it need to load in all supported language. We are finding language by currently from the browser default language

String langFromBrowser=ApexPages.currentPage().getHeaders().get('Accept-Language');

Or passing the language as a parameter. Is something similar possible?

2
  • It seems that the "correct" way to support multiple languages in community pages for guest (unauthenticated) users is to add the language selector to the page. However, this doesn't seem to have an analogue in Lightning.
    – Phil W
    Commented Jan 30, 2020 at 8:30
  • There's a way to implement this, I'll prepare my answer in some time :) Commented Jan 26, 2021 at 4:15

1 Answer 1

1

For LWC you can use internationalization properties to get the user language (as it's configured in his Salesforce profile) once he's logged in :

import LANG from '@salesforce/i18n/lang';

Then LANG value will be something like en-US, which you can use to select the correct language.

Before login or even after if you like, you can get the Accept-Language header using javascript, as described in this post : https://stackoverflow.com/questions/1043339/javascript-for-detecting-browser-language-preference

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .