This documentation is archived and is not being maintained.

Setting the Culture and Language

Windows SharePoint Services 3

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

If your code runs outside the context of Windows SharePoint Services and calls into the Windows SharePoint Services object model, when the code executes, the culture of the current thread is set according to the operating system settings of the computer on which the code is run. To interact with Windows SharePoint Services, the current UICulture and Culture values must be set to the values that are contained, respectively, by the Language and Locale properties of the SPWeb class.

Use the CurrentUICulture property to specify the language text to load and the CurrentCulture property to specify the formatting of numbers, date/time values, and so on. Following is an example of how to set these properties:

System.Threading.Thread.CurrentThread.CurrentUICulture = 
    New CultureInfo("de")
System.Threading.Thread.CurrentThread.CurrentCulture = 
    New CultureInfo("de-DE")

System.Threading.Thread.CurrentThread.CurrentUICulture = 
    new CultureInfo("de"); 
System.Threading.Thread.CurrentThread.CurrentCulture = 
    new CultureInfo("de-DE");

In this example, the CultureInfo constructor requires that a using directive (Imports in Microsoft Visual Basic) be included for the System.Globalization namespace.