SharePoint Online: Change Site Language using PowerShell
Requirement: Change the Default Language in SharePoint Online using PowerShell.
Multilingual sites are ideal for global organizations that operate in different regions of the world. The default language is the primary language used for the user interface, including the menus, buttons, and error messages. By changing the default language, you can ensure that all users accessing the site are able to navigate and interact with it in their preferred language. This tutorial will cover the steps needed to change the default language for a SharePoint Online site.
How to change the language of a SharePoint Online Site? What decides in which language the site is displayed?
Well, It depends on whether a particular language has been added to the site’s alternate languages list and the user has that specific language in his user profile language preferences! So, suppose you want your site to appear in the Arabic language. In that case, your site must have “Arabic” under the alternate language section, and the user must have “Arabic” at the top of the preferred language settings! Let’s see how to change the default language settings on SharePoint Online sites.
The default Language of the SharePoint Online Site
The language you select during a site collection or subsite creation will become the “Default” language of the site. The site’s default language will remain the same – we can’t change it! But suppose the users visiting the site have one of the alternate languages of the site added in their personal Office 365 language settings. In that case, the site will be displayed in that language.
So, you need to ensure your SharePoint site supports the language you want the site to appear under the “Alternate language”!
Add alternate language in SharePoint Online
To add alternate languages to the SharePoint Online site, follow these steps:
- Click on Settings gear Icon >> Click on Site Information >> View All Site Settings
- On the site settings page, click on “Language Settings” under the Site Administration section.
- In the Alternate Language(s) section, check the checkbox for the languages you want users to be able to use to display their user interfaces.
- Click OK to save your changes.
SharePoint Online: Add Alternate Language using PowerShell
To get all available languages on the site, run:
#Config Variables
$SiteURL = "https://crescent.sharepoint.com/sites/It"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
#Get the Web
$Web = Get-PnPWeb -Includes RegionalSettings.InstalledLanguages
#Get Available Languages
$Web.RegionalSettings.InstalledLanguages
This PowerShell script gives you all available languages and their shortcode and ID. You can add alternate language to the site as:
#Set variables
$SiteURL = "https://crescent.sharepoint.com/sites/marketing"
$LanguageID = 1025 #Arabic
#Connect to PnP Online
#Connect-PnPOnline -Url $SiteURL -Interactive
#Get the Web
$Web = Get-PnPWeb
#Add Alternate Language
$Web.IsMultilingual = $True
$Web.AddSupportedUILanguage($LanguageID)
$Web.Update()
Invoke-PnPQuery
Similarly, we can add alternate language to all site collections (so that subsites inherit this setting) using CSOM PowerShell as:
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Function to add alternate language
Function Add-SPOAlternateLanguage
{
param (
[Parameter(Mandatory=$true,Position=1)]
[string]$SiteURL,
[Parameter(Mandatory=$true,Position=2)]
[Int]$LanguageID
)
Try {
#Set the Context
$Ctx=New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Get the Web
$Web = $Ctx.Web
$Ctx.Load($Web)
$Ctx.ExecuteQuery()
Write-Host "Adding Alternate Language on Site:"$Web.Url
$Web.IsMultilingual=$true
$Web.AddSupportedUILanguage($LanguageID)
$Web.Update()
$Ctx.ExecuteQuery()
}
Catch {
write-host -f Red "Error Setting Alternate Language:" $_.Exception.Message
}
}
#Config Parameters
$AdminCenterUrl = "https://crescent-admin.sharepoint.com"
$LanguagID = 1025
#Connect to SharePoint Online
$Cred = Get-Credential
Connect-SPOService $AdminCenterUrl -Credential $Cred
#Get All Site Collection URLs
$Sites= (Get-SPOSite).Url
#Loop through Each site collection
ForEach($SiteURL in $Sites)
{
#Call the Function to Add Alternate Language
Add-SPOAlternateLanguage $SiteURL $LanguagID
}
Change User Language Preference of a User from Admin Center
The site’s language is not just based on the default language or alternate language, but it’s based on the user’s preferred language settings. As an administrator, You can set the user’s preferred language through the user profile service.
- Login to SharePoint Online Admin Center at https://tenant-admin.sharepoint.com >> Click on the “More Features” link in the left navigation
- On the “More Features” page, click on the “Open” button under “User Profiles”
- On the User Profiles page, click on the “Manage User Profiles” link.
- Search and find the user profile >> Click on the “Edit My Profile” link from the desired user profile’s context menu.
- Scroll down and under “Language Preferences”, add desired languages to the list, and set the order of preference.
- Once completed, click on “Save and Close” from the bottom of the page.
Set Preferred Language in User Profile using PowerShell
Let’s add “Arabic” and “English” Languages to the user’s profile using PnP PowerShell.
#Set variables
$AdminCenterURL = "https://crescent-admin.sharepoint.com/"
$UserAccount = "Salaudeen@crescent.com"
#Connect to PnP Online
Connect-PnPOnline -Url $AdminCenterURL -Interactive
#Update User Profile Property
Set-PnPUserProfileProperty -Account $UserAccount -PropertyName "SPS-MUILanguages" -Values "ar-SA,en-US"
Set Language Preference for a User: Self-Service
End-users can set their language preferences in SharePoint. Here is how:
- Login to SharePoint Online Site >> Click on your name icon from the top-right corner of the screen. Click on the “My Office Profile” link from the menu.
- This takes you to your delve profile. Click on the “Update Profile” button on the page.
- On the Update your profile page, expand the “How can I change language and regional settings?” link and click on click “Here” link.
- In the “Edit Details” page of your user profile, click on the ellipsis and choose “language and regional”
- Under My Display Languages, pick a new language from the drop-down menu, then click Add.
- Click Save all and close. You’ll get a dialog with the message, “Your changes have been saved, but they may take some time to take effect. Don’t worry if you don’t see them right away”.
This changes the UI to Arabic for selected users:
This profile change reflects in SharePoint and OneDrive for Business sites.
Conclusion
In conclusion, changing the default language for a SharePoint Online site is a simple process that can greatly enhance the user experience. By setting the default language to match the primary language of the users accessing the site, you can ensure that they are able to navigate and interact with the site in a way that is comfortable and familiar to them. This tutorial covered the steps needed to change the default language for a SharePoint Online site, including connecting to the site, identifying the desired language, and making the change.
What is the command to identify the site default language
Use:
$Web = Get-PnPWeb -Includes Language
$Web.Language
This gets you the language code for the web!