Testing user preferred language of SharePoint site with PnP PowerShell

Are you testing SharePoint multi-lingual features? And want a quick way to switch languages on a site for a particular user or yourself; this can be useful when testing the modern multi-lingual features in SharePoint if you want to check the quality of the pages translated.

A while ago I created a page that can serve as a reference for the codes for each language within SharePoint, mainly so I can refer to this quickly, especially during the MSDN to Microsoft Docs transition where some reference material wasn’t easy to find. Check this out: https://capacreative.co.uk/resources/reference-sharepoint-online-languages-ids/

You can set the language preferences in your user profile, by going to Delve > Update Profile > “ How can I change my language and regional settings ?” > Click “…” > Language and Region settings, so a few steps to get to these options. The change of preference can take a few minutes to propagate to all the sites in the tenant. Too slow for a quick play or testing language scenarios.

Before applying script in English

I have written a script that changes the MUI setting for a user within the User Information List to update the user with the appropriate language tag. Check out this code sample below to achieve this, here is the link if you cannot see the sample.

Connect-PnPOnline https://<tenant>.sharepoint.com/sites/<site>
Get-PnPListItem List "User Information List" Id 7 # Me
# -OR- #
$userEmail = "paul.bullock@mytenant.co.uk"
$CamlQuery = @"
<FieldRef Name='EMail' />
<Value Type='Text'>$userEmail</Value>
$item = Get-PnPListItem List "User Information List" Query $CamlQuery
# Language Reference: https://capacreative.co.uk/resources/reference-sharepoint-online-languages-ids/
$item["MUILanguages"] = "cy-GB" #"en-GB"
After Applying script in Welsh

Sharing is Caring, Enjoy!

1 comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: