In one of the SharePoint development projects that I am following we are working with multilingual sites in a SharePoint 2010 Foundation environment. As you probably already know, SharePoint 2010 allows to install language packs to provide the UI in different languages. If you want to enable multilingual UI on your site, you have to do this in SharePoint 2010 Foundation by changing these settings under Site-Settings –> Languages of every Team site.
Therefore, I wanted to write a PowerShell script that automates this manual process.
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
$siteUrl = "http://foundation"
$uiCulture = 1040;
$rootSite = Get-SPSite $siteUrl
$allWebs = $rootSite.AllWebs
foreach ($web in $allWebs) {
Write-Host "Updating " + $web.Title + " " + $web.Url
if ($web.IsMultilingual -eq $false) {
$web.IsMultilingual = $true;
}
$web.AddSupportedUICulture($uiCulture);
$web.Update()
}
The script above simply loops through the site collection defined in “$siteUrl” and loops through all sub-sites. It enables Multilanguage support if it was not already done and assigns by using the “AddSupportedUICulture” method the desired language.
This script works only if you have some language packs installed in your environment. The 1040 UI code defined in “$uiCulture” stands for the Italian language. Every language has its own unique identifier. Find here more information about localization in ASP.NET applications.
Use the script in a testing/dev environment before executing it somewhere else
Hope this helps,
Patrick


Recent Comments