Adding all installed languages to web

31/01/2012 17:59

$webUrl = "https://yoursitecollectionweb"

$web = $null #in case of troubles

$web = Get-SPWeb $webUrl

 

#find out what is already turned on, if not multilingual, set it up

$web.IsMultilingual

$web.SupportedUICultures

 

#Turn on englisn language

$culture = New-Object System.Globalization.CultureInfo(1033)

$web.AddSupportedUICulture($culture)

$web.OverwriteTranslationsOnChange = $true

$web.Update()

 

Write-Host "Current supprorted`n"

$web.SupportedUICultures

$web.OverwriteTranslationsOnChange

 

Or more generic- for each web on your site collection:

Try
 {
 $site = Get-SPSite -Identity https://yoursitecollection
 
$site | Get-SPWeb -limit all | ForEach-Object {
 
$templates = $site.GetWebTemplates($_.Language)
 $template = $templates[$_.WebTemplate]
 
if($template.SupportsMultiLingualUI)
 {
 $_.IsMultiLingual = $true
 
$installedLanguages = [Microsoft.SharePoint.SPRegionalSettings]::GlobalInstalledLanguages ;
 $supportedUICultures = $_.SupportedUICultures ;
 
ForEach($language in $installedLanguages)
 {
 $culture = New-Object System.Globalization.CultureInfo($language.LCID)
 $selected = $supportedUICultures | Where-Object{$_.LCID -eq $language.LCID}
 if($selected -eq $null)
 {
 Write-Host “Adding ” $culture.Name ” to web ” $_.Url
 $_.AddSupportedUICulture($culture)
 }
 }
 
$_.OverwriteTranslationsOnChange = $true;
 $_.Update()
 }
 
}
 }
 Catch
 {
 Write-Warning “An Error Occurred…”
 Write-Error $_
 }
 

#Solution as file with parameters

param($webUrl, $lcid)

 

    $web = Get-SPWeb $webUrl

 

    #if not multilingual, set it up

    if(-not $web.IsMultilingual)

    {

        $web.IsMultilingual = $true

    }

    #Turn on language

    $language = $web.SupportedUICultures | where {$_.LCID -eq $lcid}

    $culture = New-Object System.Globalization.CultureInfo($lcid)

    if(-not $language)

    {

        "Turning on language '{0}' on '{1}'" -f $culture.DisplayName, $webUrl

 

        #enable language

        $web.AddSupportedUICulture($culture)

        $web.OverwriteTranslationsOnChange = $true

        $web.Update()

    }

    else

    {

        "Language '{0}' is already enabled on '{1}'" -f $culture.DisplayName, $webUrl

    }

    if($web.Locale.LCID -eq $lcid)

    {

        "Culture '{0}' is already set in Regional settings on '{1}'" -f $culture.DisplayName, $webUrl

    }

    else

    {

        "Setting culture '{0}' in Regional settings on '{1}'" -f $culture.DisplayName, $webUrl

        #Adjust Regional settings

        $web.Locale = $culture

    }

    "Setting time format to 24 hod..."

    $web.RegionalSettings.Time24 = $true

 

    "Setting 'Monday' as first day of week..."

    $web.RegionalSettings.FirstDayOfWeek = 1

    $web.Update()

    $web.Dispose();