SPWeb.AddSupportedUICulture Method
Adds culture-specific information to the list supported by the website.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
Syntax
'Declaration
Public Sub AddSupportedUICulture ( _
cultureInfo As CultureInfo _
)
'Usage
Dim instance As SPWeb
Dim cultureInfo As CultureInfo
instance.AddSupportedUICulture(cultureInfo)
public void AddSupportedUICulture(
CultureInfo cultureInfo
)
Parameters
cultureInfo
Type: System.Globalization.CultureInfoThe culture-specific information to add.
Remarks
This method adds the information about the culture to the list in the SupportedUICultures property.
Use this method to add a language to the list of alternative languages supported by the website's multilingual user interface (UI). Any language that you add should already be installed on the server farm. A list of installed language packs is returned by the SPRegionalSettings.GlobalInstalledLanguages property.
Warning
Some web templates do not support the multilingual UI. Before you call this method, check the value of the SupportsMultilingualUI property of the web template that was used to create the website.
Examples
The following example is a console application that enumerates the installed languages and adds any that are currently not supported to the list of supported cultures.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Microsoft.SharePoint;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("https://localhost"))
{
using (SPWeb web = site.OpenWeb())
{
// Be sure the web template supports MUI. Some templates do not.
if (site.GetWebTemplates(web.Language)[web.WebTemplate].SupportsMultilingualUI)
{
// Enable MUI.
web.IsMultilingual = true;
// Get the languages that are installed on the farm.
SPLanguageCollection installed = SPRegionalSettings.GlobalInstalledLanguages;
// Get the languages supported by this website.
IEnumerable<CultureInfo> supported = web.SupportedUICultures;
// Enable support for any installed language that is not already supported.
foreach (SPLanguage language in installed)
{
CultureInfo culture = new CultureInfo(language.LCID);
if (!supported.Contains(culture))
{
Console.WriteLine("Adding {0}", culture.Name);
web.AddSupportedUICulture(culture);
}
}
web.Update();
}
}
}
Console.Write("\nPress ENTER to continue....");
Console.Read();
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Globalization
Imports System.Linq
Imports Microsoft.SharePoint
Module ConsoleApp
Sub Main()
Using site As New SPSite("https://localhost")
Using web As SPWeb = site.OpenWeb()
' Be sure the web template supports MUI. Some templates do not.
If site.GetWebTemplates(web.Language)(web.WebTemplate).SupportsMultilingualUI Then
' Enable MUI.
web.IsMultilingual = True
' Get the languages that are installed on the farm.
Dim installed As SPLanguageCollection = SPRegionalSettings.GlobalInstalledLanguages
' Get the languages supported by this website.
Dim supported As IEnumerable(Of CultureInfo) = web.SupportedUICultures
' Enable support for any installed language that is not already supported.
For Each language As SPLanguage In installed
Dim culture As New CultureInfo(language.LCID)
If Not supported.Contains(culture) Then
Console.WriteLine("Adding {0}", culture.Name)
web.AddSupportedUICulture(culture)
End If
Next
web.Update()
End If
End Using
End Using
Console.Write(vbLf & "Press ENTER to continue...")
Console.ReadLine()
End Sub
End Module