SPRegionalSettings.GlobalInstalledLanguages 属性

请注意:此 API 现在已过时。

获取服务器安装的语言包的集合。

命名空间:  Microsoft.SharePoint
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
<ObsoleteAttribute("Use SPLanguageSettings::GetGlobalInstalledLanguages instead")> _
Public Shared ReadOnly Property GlobalInstalledLanguages As SPLanguageCollection
    Get
用法
Dim value As SPLanguageCollection

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

属性值

类型:Microsoft.SharePoint.SPLanguageCollection
一个代表安装的语言包的SPLanguageCollection对象。

示例

下面的示例是一个控制台应用程序,该枚举已安装的语言,并将添加到列表中的多语言用户界面支持的区域性的任何当前不支持。

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();
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Globalization
Imports System.Linq
Imports Microsoft.SharePoint

Module ConsoleApp

    Sub Main()
        Using site As New SPSite("https://localhost")
            Using web As SPWeb = site.OpenWeb()

                web.IsMultilingual = True

                Dim installed As SPLanguageCollection = SPRegionalSettings.GlobalInstalledLanguages
                Dim supported As IEnumerable(Of CultureInfo) = web.SupportedUICultures

                For Each language As SPLanguage In installed
                    Dim culture As New CultureInfo(language.LCID)

                    If Not supported.Contains(culture) Then
                        Console.WriteLine("Adding {0}", culture.Name)
                        web.AddSupportedUICulture(culture)
                    End If
                Next
                web.Update()

            End Using
        End Using
        Console.Write(vbCrLf + "Press ENTER to continue....")
        Console.Read()
    End Sub
End Module

另请参阅

引用

SPRegionalSettings 类

SPRegionalSettings 成员

Microsoft.SharePoint 命名空间