Export (0) Print
Expand All

SPContentType.GetLocalizations method

Returns the collection of localizations for the content type for the specified culture.

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

public SPLocalizationCollection GetLocalizations(
	CultureInfo cultureInfo
)

Parameters

cultureInfo
Type: System.Globalization.CultureInfo

An object that specifies a culture.

Return value

Type: Microsoft.SharePoint.SPLocalizationCollection
A dictionary of strings that represent the locales that are supported by the content type. For a list content type, the SPLocalizationCollection object is a null reference (Nothing in Visual Basic).

The following example is part of a console application that iterates through the collection of site content types and prints the number of localizations for each type.

SPSite site = new SPSite("http://localhost");
SPWeb web = site.OpenWeb();

Console.WriteLine("The site locale is " + web.Locale.Name);
Console.WriteLine("The culture identifier (Lcid) is " + web.Language.ToString());

foreach (SPContentType contentType in web.ContentTypes)
{
    SPLocalizationCollection localizations = 
        contentType.GetLocalizations(web.Locale);
    Console.Write("The {0} content type has ", contentType.Name);
    Console.WriteLine(" {0} localizations", localizations.Count.ToString());
}

// Clean up.
web.Dispose();
site.Dispose();
Show:
© 2014 Microsoft