Export (0) Print
Expand All
Expand Minimize

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

[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.

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

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("http://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();
        }
    }
}
Show:
© 2014 Microsoft