0

So this is driving me crazy! Please help :)

I'm using the PnP.PowerShell module to enable multi-lingual support on a SharePoint Online site. I'm taking the following steps.

  1. Create a communication site through the SharePoint admin centre
  2. Run the following PowerShell script:
$SiteURL = 'https://tenant.sharepoint.com/sites/test'
$SiteConnection = Connect-PnPOnline -Url $SiteURL -Interactive
Enable-PnPFeature -Identity 24611c05-ee19-45da-955f-6602264abaf8 -Connection $SiteConnection -Scope Web

This toggles the 'Enable translation into multiple languages' setting at the following URL 'https://tenant.sharepoint.com/sites/test/_layouts/15/muisetng.aspx' which is great and exactly what I want. However, it also enables every site language. I only want to enable a couple of languages.

Has anyone else tried the above? Not sure why this is happening.

I'm using PnP.PowerShell version 2.2.0

dev123
  • 25
  • 1
  • 9

1 Answers1

0

The Multilingual Page Publishing feature does not enable or disable alternate site languages. By default, Communication sites are created with all 50 languages enabled. Some other site types have no alternate languages enabled. When you add the feature using the "Enable translation into multiple languages" slider, it is not just adding the feature, it is actually deleting all the alternate languages, as you can see by clicking on "show advanced settings" before and after you enable it. You must add and delete the alternate languages that you want using Web.AddSupportedUILanguage or Web.RemoveSupportedUILanguage, for example:

#Set variables
$SiteURL = "https://mytenant.sharepoint.com/sites/mysite"
$LanguageID = 1036 #French
 
#Get the web
Connect-PnPOnline -Url $SiteURL -Interactive
$Web = Get-PnPWeb
 
#Add Alternate Language
$Web.AddSupportedUILanguage($LanguageID)
$Web.Update()
Invoke-PnPQuery