SPWeb.Language-Eigenschaft
Ruft den Gebietsschemabezeichner (LCID) für die Standardsprache der Website ab.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaration
Public ReadOnly Property Language As UInteger
Get
'Usage
Dim instance As SPWeb
Dim value As UInteger
value = instance.Language
public uint Language { get; }
Eigenschaftswert
Typ: System.UInt32
Eine 32-Bit-Ganzzahl, die angibt, die LCID für die Sprache. Eine Liste der LCIDs finden Sie unter der SPLocale.LCID -Eigenschaft.
Hinweise
Die Standardsprache einer Website kann festgelegt werden, nur, wenn die Website erstellt wurde. Websitebesitzer kann später alternative Sprachen mithilfe der mehrsprachigen Benutzeroberfläche oder durch Festlegen der IsMultilingual -Eigenschaft aktivieren.
Beispiele
Im folgende Beispiel wird eine Konsolenanwendung, die den Namen LCID und die Anzeigenamenwerte für jede Sprache in der Farm installiert, der Standardsprache der Website und jede Alternative Sprache an, von der Website unterstützt wird gedruckt.
using System;
using System.Collections.Generic;
using System.Globalization;
using Microsoft.SharePoint;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("https://localhost"))
{
using (SPWeb web = site.RootWeb)
{
string format = "{0} | {1}";
// Display the languages installed on the farm.
Console.WriteLine("Installed Languages");
SPLanguageCollection languages = SPRegionalSettings.GlobalInstalledLanguages;
foreach (SPLanguage language in languages)
{
Console.WriteLine(format, language.LCID, language.DisplayName);
}
// Display the default language for the website.
int lcid = (int)web.Language;
CultureInfo defaultCulture = new CultureInfo(lcid);
Console.WriteLine("\nDefault Language");
Console.WriteLine(format, defaultCulture.LCID, defaultCulture.DisplayName);
// Display the alternate languages for the website.
if (web.IsMultilingual)
{
Console.WriteLine("\nAlternate Languages");
IEnumerable<CultureInfo> cultures = web.SupportedUICultures;
foreach (CultureInfo culture in cultures)
{
if (culture.LCID == defaultCulture.LCID)
continue;
Console.WriteLine(format, culture.LCID, culture.DisplayName);
}
}
}
}
Console.Write("\nPress ENTER to continue....");
Console.Read();
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Globalization
Imports Microsoft.SharePoint
Module ConsoleApp
Sub Main()
Using site As New SPSite("https://localhost")
Using web As SPWeb = site.OpenWeb()
Dim format As String = "{0} | {1}"
' Display the languages installed on the farm.
Console.WriteLine("Installed Languages")
Dim languages As SPLanguageCollection = SPRegionalSettings.GlobalInstalledLanguages
For Each language As SPLanguage In languages
Console.WriteLine(format, language.LCID, language.DisplayName)
Next
' Display the default language for the website.
Dim lcid As Integer = CInt(web.Language)
Dim defaultCulture As New CultureInfo(lcid)
Console.WriteLine(vbLf & "Default Language")
Console.WriteLine(format, defaultCulture.LCID, defaultCulture.DisplayName)
' Display the alternate languages for the website.
If web.IsMultilingual Then
Console.WriteLine(vbLf & "Alternate Languages")
Dim cultures As IEnumerable(Of CultureInfo) = web.SupportedUICultures
For Each culture As CultureInfo In cultures
If culture.LCID = defaultCulture.LCID Then
Continue For
End If
Console.WriteLine(format, culture.LCID, culture.DisplayName)
Next
End If
End Using
End Using
Console.Write(vbCrLf & "Press ENTER to continue....")
Console.Read()
End Sub
End Module