Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
SupportedUICultures property
Collapse the table of content
Expand the table of content

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)

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:
© 2015 Microsoft