Partilhar via


SPWeb.SupportedUICultures Property

Gets an enumerable collection of objects with information about cultures supported by the website.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
Available in SharePoint Online

Syntax

'Declaration
<SubsetCallableExcludeMemberAttribute(SubsetCallableExcludeMemberType.InterfaceType)> _
Public ReadOnly Property SupportedUICultures As IEnumerable(Of CultureInfo)
    Get
'Usage
Dim instance As SPWeb
Dim value As IEnumerable(Of CultureInfo)

value = instance.SupportedUICultures
[SubsetCallableExcludeMemberAttribute(SubsetCallableExcludeMemberType.InterfaceType)]
public IEnumerable<CultureInfo> SupportedUICultures { get; }

Property Value

Type: System.Collections.Generic.IEnumerable<CultureInfo>
An enumerable collection of CultureInfo objects representing cultures that are enabled for this website. The CultureInfo objects are not returned in any particular order.

Remarks

The AddSupportedUICulture method adds cultures to the list of supported cultures. The default culture is returned by the UICulture property.

Examples

The following example is a console application that prints the names of cultures supported by the site and also the name of the default culture for the site.

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using Microsoft.SharePoint;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("https://localhost"))
            {
                using (SPWeb web = site.RootWeb)
                {
                    if (web.IsMultilingual)
                    {
                        StringBuilder sb = new StringBuilder();
                        string sep = ", ";

                        IEnumerable<CultureInfo> cultures = web.SupportedUICultures;

                        foreach (CultureInfo culture in cultures)
                        {
                            sb.Append(culture.Name);
                            sb.Append(sep);
                        }

                        string str = sb.ToString().Trim(sep.ToCharArray());
                        Console.WriteLine("Supported cultures: {0}", str);
                    }
                    Console.WriteLine("Default culture: {0}", web.UICulture.Name);
                }
            }
            Console.WriteLine("\nPress ENTER to continue....");
            Console.Read();
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Globalization
Imports System.Text
Imports Microsoft.SharePoint

Module ConsoleApp

    Sub Main()
        Using site As New SPSite("https://localhost")
            Using web As SPWeb = site.RootWeb
                If web.IsMultilingual Then

                    Dim sb As New StringBuilder()
                    Dim sep As String = ", "

                    Dim cultures As IEnumerable(Of CultureInfo) = web.SupportedUICultures

                    For Each culture As CultureInfo In cultures
                        sb.Append(culture.Name)
                        sb.Append(sep)
                    Next

                    Dim str As String = sb.ToString().Trim(sep.ToCharArray())
                    Console.WriteLine("Supported cultures: {0}", str)
                End If
                Console.WriteLine("Default culture: {0}", web.UICulture.Name)
            End Using
        End Using

        Console.Write(vbCrLf & "Press ENTER to continue....")
        Console.Read()
    End Sub

End Module

See Also

Reference

SPWeb Class

SPWeb Members

Microsoft.SharePoint Namespace

IsMultilingual

UICulture

AddSupportedUICulture(CultureInfo)