Share via


SPUserResource.SetValueForUICulture-Methode

Legt den Wert der Ressource für die angegebene Kultur.

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

Syntax

'Declaration
Public Sub SetValueForUICulture ( _
    cultureInfo As CultureInfo, _
    value As String _
)
'Usage
Dim instance As SPUserResource
Dim cultureInfo As CultureInfo
Dim value As String

instance.SetValueForUICulture(cultureInfo, _
    value)
public void SetValueForUICulture(
    CultureInfo cultureInfo,
    string value
)

Parameter

  • value
    Typ: System.String

    Eine Zeichenfolge, die den Wert der Ressource in der angegebenen Kultur enthält.

Ausnahmen

Ausnahme Bedingung
ArgumentNullException

cultureInfo ist Null .

Beispiele

Das folgende Beispiel ist eine Konsolenanwendung, die erstellt eines neue Navigationsknotens, die eine Verknüpfung zur Liste Ankündigungen und den Schnellstartbereich der Website den Knoten hinzugefügt. Die Anwendung dann durchlaufen und die Liste der Sprachen, die von der Website der mehrsprachigen Benutzeroberfläche unterstützt und ruft SetValueForUICulture zum Schreiben von lokalisierten Werte aus der Ankündigungsliste TitleResource -Eigenschaft auf den Knoten TitleResource -Eigenschaft.

using System;
using System.Globalization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Navigation;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("https://localhost"))
            {
                using (SPWeb web = site.RootWeb)
                {
                    web.QuickLaunchEnabled = true;
                    web.IsMultilingual = true;

                    SPList list = web.Lists.TryGetList("Announcements");
                    if (list != null)
                    {
                        // Create a navigation node pointing to the Announcements list.
                        SPNavigationNode newNode = new SPNavigationNode(list.Title, list.DefaultViewUrl);

                        // Add the node to the Quick Launch area.
                        SPNavigationNodeCollection quickLaunch = web.Navigation.QuickLaunch;
                        quickLaunch.AddAsLast(newNode);

                        // Copy translations of the list's title to the user resource for the node's title.
                        string localizedTitle;
                        SPUserResource titleResource = newNode.TitleResource;
                        foreach (CultureInfo culture in web.SupportedUICultures)
                        {
                            localizedTitle = list.TitleResource.GetValueForUICulture(culture);
                            newNode.TitleResource.SetValueForUICulture(culture, localizedTitle);
                        }
                        newNode.Update();
                    }
                }
            }
            Console.Write("\nPress ENTER to continue....");
            Console.Read();
        }
    }
}
Imports System
Imports System.Globalization
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Navigation

Module ConsoleApp

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

                web.QuickLaunchEnabled = True
                web.IsMultilingual = True

                Dim list As SPList = web.Lists.TryGetList("Announcements")
                If list IsNot Nothing Then
                    ' Create a navigation node pointing to the Announcements list.
                    Dim newNode As New SPNavigationNode(list.Title, list.DefaultViewUrl)

                    ' Add the node to the Quick Launch area.
                    Dim quickLaunch As SPNavigationNodeCollection = web.Navigation.QuickLaunch
                    quickLaunch.AddAsLast(newNode)

                    ' Copy translations of the list's title to the user resource for the node's title.
                    Dim localizedTitle As String
                    Dim titleResource As SPUserResource = newNode.TitleResource
                    For Each culture As CultureInfo In web.SupportedUICultures
                        localizedTitle = list.TitleResource.GetValueForUICulture(culture)
                        newNode.TitleResource.SetValueForUICulture(culture, localizedTitle)
                    Next
                    newNode.Update()
                End If

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

End Module

Siehe auch

Referenz

SPUserResource Klasse

SPUserResource-Member

Microsoft.SharePoint-Namespace