SPUtility.SetThreadCulture method (SPWeb)

Sets the thread and user interface (UI) culture based on the values of the LocaleId property and the PreferredDisplayLanguages property, respectively, for the current user. If the current user cannot be determined, the culture is set based on the value of the Locale property and language on the value of the Language property.

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

Syntax

'Declaration
Public Shared Sub SetThreadCulture ( _
    spWeb As SPWeb _
)
'Usage
Dim spWeb As SPWebSPUtility.SetThreadCulture(spWeb)
public static void SetThreadCulture(
    SPWeb spWeb
)

Parameters

Remarks

The SetThreadCulture method does two things:

  • It sets the value of the CurrentThread.CurrentCulture property on the thread.

    • If the user can be determined, the thread's culture is set to a CultureInfo object using the value of the user's LocaleId from RegionalSettings.

    • If the user cannot be determined, the thread's culture is set to the value of the web's Locale property.

  • Sets the value of the CurrentThread.CurrentUICulture property on the thread.

    • If the web’s IsMultilingual property is false, then the UI Culture is set to the value of the web’s Language property.

    • If the web’s IsMultilingual property is true, then one of the following happens:

      • If the user cannot be determined, the UI Culture is set to the web’s Language property.

      • If the user can be determined, SharePoint employs a language fallback algorithm SPLanguageSettings.TryDetermineLanguage (https://msdn.microsoft.com/en-us/library/jj168842.aspx) to determine which UI culture to use. The algorithm relies on the user’s SPUser.LanguageSettings.PreferredDisplayLanguages, the web’s SPWeb.Language property, as well as all MUI languages the web specifies that are installed on the server.

For more information, see Using the CurrentCulture Property.

See also

Reference

SPUtility class

SPUtility members

SetThreadCulture overload

Microsoft.SharePoint.Utilities namespace