共用方式為


SPRegionalSettings.InstalledLanguages property

會取得伺服器陣列中的網頁伺服器上所安裝的語言集合。

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

Syntax

'宣告
Public ReadOnly Property InstalledLanguages As SPLanguageCollection
    Get
'用途
Dim instance As SPRegionalSettings
Dim value As SPLanguageCollection

value = instance.InstalledLanguages
public SPLanguageCollection InstalledLanguages { get; }

Property value

Type: Microsoft.SharePoint.SPLanguageCollection
SPLanguageCollection 物件,代表已安裝的語言。

備註

安裝在伺服器陣列中的第一個語言是SKU 語言— SharePoint Foundation 2010已安裝的語言。您可以透過存取靜態GlobalServerLanguage屬性來探索 SKU 語言。其他語言由伺服器陣列管理員可以在伺服器陣列中網頁伺服器安裝的語言套件新增至集合。如需可用的語言套件的清單,請參閱 < Language Packs for SharePoint Foundation 2010

當伺服器陣列中安裝的語言時,請他們未自動啟用特定網站的多語系使用者介面中使用。這必須完成一個獨立步驟為網站擁有者,成員可存取在使用者介面中,然後語言設定] 頁面上的 [網站設定] 頁面。在其他語言群組是已安裝的語言清單。多語系使用者介面新增語言,由其名稱旁邊的方塊。可執行程式碼,列舉的已安裝的語言集合,並呼叫AddSupportedUICulture(CultureInfo)方法會啟用支援的各種語言完成相同的工作。

Examples

下列範例會列舉已安裝的語言,並以支援多語系使用者介面的文化特性的清單中新增 [任何,目前不支援的主控台應用程式。

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();
        }
    }
}
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 = web.RegionalSettings.InstalledLanguages
                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 class

SPRegionalSettings members

Microsoft.SharePoint namespace

SupportedUICultures