ยท 2 min read
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
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: Reference SharePoint Online Languages
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:
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 = @"
<View>
<Query>
<Where>
<Eq>
<FieldRef Name='EMail' />
<Value Type='Text'>$userEmail</Value>
</Eq>
</Where>
</Query>
</View>
"@
$item = Get-PnPListItem -List "User Information List" -Query $CamlQuery
$item["MUILanguages"] = "cy-GB" #"en-GB"
$item.Update()
Invoke-PnPQuery
After Applying script in Welsh
Sharing is Caring, Enjoy!