Share via


SPRegionalSettings.GlobalInstalledLanguages property

NOTE: This API is now obsolete.

Gets the collection of language packs that are installed on the server.

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

Syntax

[ObsoleteAttribute("Use SPLanguageSettings::GetGlobalInstalledLanguages instead")]
public static SPLanguageCollection GlobalInstalledLanguages { get; }

Property value

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

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 = SPRegionalSettings.GlobalInstalledLanguages;
                    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