共用方式為


SPWeb.SupportedUICultures property

取得可列舉的網站所支援的文化特性的相關資訊的物件集合。

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

Syntax

'宣告
Public ReadOnly Property SupportedUICultures As IEnumerable(Of CultureInfo)
    Get
'用途
Dim instance As SPWeb
Dim value As IEnumerable(Of CultureInfo)

value = instance.SupportedUICultures
public IEnumerable<CultureInfo> SupportedUICultures { get; }

Property value

Type: System.Collections.Generic.IEnumerable<CultureInfo>
表示啟用此網站的文化特性的CultureInfo物件可列舉的集合。CultureInfo物件不會傳回任何特定順序。

備註

AddSupportedUICulture方法會加入支援的文化特性的清單中的文化特性。UICulture屬性會傳回預設文化特性。

Examples

下列範例是一個主控台應用程式,列印的站台所支援的文化特性名稱以及網站的預設文化特性名稱。

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("https://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();
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Globalization
Imports System.Text
Imports Microsoft.SharePoint

Module ConsoleApp

    Sub Main()
        Using site As New SPSite("https://localhost")
            Using web As SPWeb = site.RootWeb
                If web.IsMultilingual Then

                    Dim sb As New StringBuilder()
                    Dim sep As String = ", "

                    Dim cultures As IEnumerable(Of CultureInfo) = web.SupportedUICultures

                    For Each culture As CultureInfo In cultures
                        sb.Append(culture.Name)
                        sb.Append(sep)
                    Next

                    Dim str As String = sb.ToString().Trim(sep.ToCharArray())
                    Console.WriteLine("Supported cultures: {0}", str)
                End If
                Console.WriteLine("Default culture: {0}", web.UICulture.Name)
            End Using
        End Using

        Console.Write(vbCrLf & "Press ENTER to continue....")
        Console.Read()
    End Sub

End Module

請參閱

參照

SPWeb class

SPWeb members

Microsoft.SharePoint namespace

IsMultilingual

UICulture

AddSupportedUICulture(CultureInfo)