Share via


SPRegionalSettings.InstalledLanguages property

Gets the collection of languages installed on Web servers in the farm.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

public SPLanguageCollection InstalledLanguages { get; }

Property value

Type: Microsoft.SharePoint.SPLanguageCollection
An SPLanguageCollection object that represents the installed languages.

Remarks

The first language that is installed in a farm is the SKU language — the language in which SharePoint Foundation 2010 is installed. You can discover the SKU language by accessing the static GlobalServerLanguage property. Other languages are added to the collection by language packs that farm administrators can install on the Web servers in the farm. For a list of the language packs that are available, see Language Packs for SharePoint Foundation 2010.

When languages are installed in the farm, they are not automatically enabled for use in the multilingual user interface for a given Web site. This must be done as a separate step by the site owner, who can access Site Settings page in the user interface, then the Language Settings page. In the Alternate language(s) group is a list of installed languages. A language is added to the multilingual user interface by checking the box next to its name. The same task can be accomplished by executing code that enumerates the collection of installed languages and enables support for each language by calling the AddSupportedUICulture(CultureInfo) method.

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 cultures supported by the multilingual user interface.

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.RootWeb)
                {
                    web.IsMultilingual = true;

                    SPLanguageCollection installed = web.RegionalSettings.InstalledLanguages;
                    IEnumerable<CultureInfo> supported = web.SupportedUICultures;

                    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();
        }
    }
}

See also

Reference

SPRegionalSettings class

SPRegionalSettings members

Microsoft.SharePoint namespace

SupportedUICultures