How to Localize Site Columns in SharePoint 2010 Using Visual Studio 2010

Introduction

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

Steps Involved

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

  • Create Empty SharePoint Project
  • Create Resource files
  • Add Empty Element
  • Deploy the solution
  • Test the Localized columns

Create Empty SharePoint Project

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

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

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

    ClmShr3.jpg

Create Resource files

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

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

    ClmShr5.jpg
     
  3. Right-click on the Resources folder; select Add and click on New Item.

    ClmShr6.jpg
     
  4. Select the Resources File template from the installed templates, name it LocalizeColumns and then click on Ok.

    ClmShr7.jpg
     
  5. Double-click on LocalizeColumns.resx and add the following name and values:

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

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

    ClmShr10.jpg

Add Empty Element

  1. Right-click on the solution; select Add and then click on New Item.
  2. Select the Empty Element template from the installed templates; name it as LocalizeColumns and then click on Ok.

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

    <?xmlversion="1.0"encoding="utf-8"?>
    <Elementsxmlns="http://schemas.microsoft.com/sharepoint/">
      <FieldID="{E6D3305E-6879-4935-AE56-88F2D526258E}"
             Name="EmployeeName"
             DisplayName="$Resources:LocalizeColumns,EmployeeName"
             Type="Text"></Field>
      <FieldID="{EF87891F-7726-4772-B5EA-B435924EBFA2}"
           Name="Designation"
           DisplayName="$Resources:LocalizeColumns,Designation"
           Type="Text"></Field>
      <FieldID="{82266CE8-AEF5-478C-9CDA-B86FED9EDEAE}"
           Name="Location"
           DisplayName="$Resources:LocalizeColumns,Location"
           Type="Text"></Field>       
    </Elements>

Deploy the solution

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

Test the Localized columns

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

    ClmShr12.jpg
     
  6. Change the language to French and you will see the localized site columns as shown in the following figure:

    ClmShr13.jpg

    ClmShr14.jpg

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

Summary

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