SPWeb.AddSupportedUICulture method
加入支援的網站清單中的特定文化特性資訊。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public Sub AddSupportedUICulture ( _
cultureInfo As CultureInfo _
)
'用途
Dim instance As SPWeb
Dim cultureInfo As CultureInfo
instance.AddSupportedUICulture(cultureInfo)
public void AddSupportedUICulture(
CultureInfo cultureInfo
)
參數
cultureInfo
Type: System.Globalization.CultureInfo要加入的特定文化特性資訊。
備註
這個方法會加入到清單中的 [ SupportedUICultures ] 屬性的文化特性的相關資訊。
使用這個方法來新增語言支援的網站的多語系使用者介面 (UI) 的替代語言的清單。伺服器陣列上時,應該已安裝任何您新增的語言。SPRegionalSettings.GlobalInstalledLanguages屬性所傳回的已安裝的語言套件清單。
注意
有些 web 範本不支援多語系 UI。在呼叫這個方法之前,請檢查用來建立網站的網站範本的SupportsMultilingualUI屬性的值。
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.OpenWeb())
{
// Be sure the web template supports MUI. Some templates do not.
if (site.GetWebTemplates(web.Language)[web.WebTemplate].SupportsMultilingualUI)
{
// Enable MUI.
web.IsMultilingual = true;
// Get the languages that are installed on the farm.
SPLanguageCollection installed = SPRegionalSettings.GlobalInstalledLanguages;
// Get the languages supported by this website.
IEnumerable<CultureInfo> supported = web.SupportedUICultures;
// Enable support for any installed language that is not already supported.
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()
' Be sure the web template supports MUI. Some templates do not.
If site.GetWebTemplates(web.Language)(web.WebTemplate).SupportsMultilingualUI Then
' Enable MUI.
web.IsMultilingual = True
' Get the languages that are installed on the farm.
Dim installed As SPLanguageCollection = SPRegionalSettings.GlobalInstalledLanguages
' Get the languages supported by this website.
Dim supported As IEnumerable(Of CultureInfo) = web.SupportedUICultures
' Enable support for any installed language that is not already supported.
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 If
End Using
End Using
Console.Write(vbLf & "Press ENTER to continue...")
Console.ReadLine()
End Sub
End Module