How to Localize Content Types in SharePoint 2010 Using Visual Studio 2010

Introduction

In this article you will be seeing how to localize content types in SharePoint 2010 using Visual Studio 2010.

Steps Involved

The following steps must be performed to localize the content types in SharePoint 2010 using Visual Studio 2010:

  • Create Empty SharePoint Project
  • Create Resource files
  • Add Content Type
  • Deploy the solution
  • Test the Localized content type

Create Empty SharePoint Project

  1. Open Visual Studio as administrator.
     
  2. Go to File, select New and then click on Project.

    CntTypShr1.jpg
     
  3. Select Empty SharePoint Project from the installed templates.

    CntTypShr2.jpg
     
  4. Enter the Name as LocalizeContentType and then click on Ok.
  5. Enter the site URL and select "Deploy as farm solution".
  6. Click on Finish.

    CntTypShr3.jpg

Create Resource files

  1. Right-click on solution, select Add and then click on the SharePoint Mapped Folder.

    CntTypShr4.jpg
     
  2. Select the Resources folder and then click on Ok.

    CntTypShr5.jpg
     
  3. Right-click on the Resources folder, then select Add and click on New Item.

    CntTypShr6.jpg
     
  4. Select the Resources File template from the installed templates, name it as LocalizeContentType and then click on Ok.

    CntTypShr7.jpg
     
  5. Double-click on LocalizeContentType.resx and add the following name and values.

    CntTypShr8.jpg
     
  6. Similarly add one more resource file for the French language, name it as LocalizeContentType.fr-FR.resx and add the following name & values:

    CntTypShr9.jpg
     
  7. The Resources folder looks like the following:

    CntTypShr10.jpg

Add Content Type

  1. Right-click on solution, select Add and then click on New Item.
  2. Select the Content Type template from the installed templates, name it LocalizeContentType and then click on Ok.

    CntTypShr11.jpg
     
  3. Double-click on Elements.xml and replace with the following:

    <?xmlversion="1.0"encoding="utf-8"?>
    <Elementsxmlns="http://schemas.microsoft.com/sharepoint/">
      <!-- Parent ContentType: Item (0x01) -->
      <
    ContentTypeID="0x01000188a30d01ae4607bbe5800bbbaf2550"
                   Name="$Resources:LocalizeContentType,ContentTypeTitle"              
                   Group="Custom Content Types"
                   Description="$Resources:LocalizeContentType,ContentTypeDescription"
                   Inherits="TRUE"
                   Version="0">
        <FieldRefs>
        </
    FieldRefs>
      </
    ContentType>
    </
    Elements>

Deploy the solution

  1. Right-click on solution and click on Deploy.

Test the Localized content type:

  1. Navigate to the site, click on Site Actions.
  2. Click on Site Settings.
  3. Click on Site Content Types under Galleries section.
  4. Select Custom Content types from the Show Group drop down.
  5. You could be able to see new content type created under Custom Content Types (Will be in English which is the default language for the site).

    CntTypShr12.jpg
     
  6. Change the language to French and you could be able to see the localized content types as shown in figure:

    CntTypShr13.jpg

    CntTypShr14.jpg

Note: Make sure the language packs are installed in the SharePoint server.

Summary

Thus in this article you have seen how to localize content types in SharePoint 2010 using Visual Studio 2010.