One of our clients wanted his entire SharePoint 2010 site to utilise MUI but the MUI setting is at the web level and not the site collection level. On a site with 800 sub webs, this can become quite anoying. We provided them a powershell script that enables the MUI globally but this was going to be run by users that had no access to run powershell on the server so the code was repackaged in a SharePoint feature that enables MUI to all sub sites on feature activation.
The code itself is really simple and can also be repurposed in a WebProvisioned event receiver that can fire at site creation.
using Microsoft.SharePoint; using System.Linq; using System.Globalization; using System.Collections.Generic; public override void FeatureActivated(SPFeatureReceiverProperties properties) { try { SPSite site = properties.Feature.Parent as SPSite; foreach (SPWeb web in site.AllWebs) { web.IsMultilingual = true; // Add support for any installed language currently not supported. SPLanguageCollection installed = SPRegionalSettings.GlobalInstalledLanguages; IEnumerable supported = web.SupportedUICultures; foreach (SPLanguage language in installed) { CultureInfo culture = new CultureInfo(language.LCID); if (!supported.Contains(culture)) { web.AddSupportedUICulture(culture); } } web.Update(); } } catch (Exception ex) { } }
Update 28/09/2011: I was asked to provide a powershell script and I did but then I spent some time updating it to reflect more the C# script provided above. This powershell script will add all supported cultures to all sub sites in your environment.
Add-PSSnapin Microsoft.SharePoint.PowerShell –ErrorAction SilentlyContinue $siteurl = Read-Host "Enter Web Application URL" $installed = [Microsoft.SharePoint.SPRegionalSettings]::GlobalInstalledLanguages $site = get-spsite $siteurl foreach ($web in $site.allwebs){ $web.IsMultiLingual = 'True' $supportedCultures = $web.SupportedUICultures ; foreach ($lang in $installed){ $cultureinfo = [System.Globalization.CultureInfo]::GetCultureInfo($lang.LCID); $exists = $supportedCultures | Where-Object{$_.LCID -eq $lang.LCID} if ($exists -eq $null){ $web.AddSupportedUICulture($cultureinfo) Write-Host "Added" $cultureinfo.Name "to url" $web.Url } } $web.Update() } Write-Host "Press any key to continue ..." $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
You can download the powershell script from here. Let me know in the comments if you like this.