I have a SPFx webpart with "de" and "en" locales and want to change the language with a button in the webpart. How can i change the locales?

SPFx webpart on a modern page.


The language information are provided under the object this.context.pageContext.cultureInfo in the webpart context. This is the same object the module loader is leveraging at runtime to dynamically load this or that language, all of that is read only which means you can't override it as runtime.
This object is hydrated by the SharePoint Hosting context (in charge of bootstrapping your webpart), which in it's turn gets the information from the SharePoint user profile as well as the browser configuration (if no profile information is available).
However if you want to change the user's language, you can change the property in the user profile, keep in mind this will take time to propagate on all the sites. Also the site needs to have the language enabled to be able to offer it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.