Month: March 2013

Content Localization in SharePoint 2013 using resource files

SharePoint supports content localization to enable the site members to have a SharePoint site in their very own languages. This is very innovative feature of SharePoint with which one can create multilingual sites very easily.
When it comes to creating a multilingual site, particularly, a developer concentrates on the parts on which localization is to be applied. As we know for any SharePoint site, we have a page, where we have, page content, few webparts, header and footer.
With advent of Machine Translation Service in SharePoint 2013, one can easily have a translation of page content by using Microsoft Translator Service. As far as other parts of the page are concerned, web part, particularly, can have some difficulties translating each and every content.
For the same, we can use a resource file, which will enable the webpart interface to adopt to specific language. In this particular post, I will be describing a step by step method to get some content localized by using resource file.

Instructions to create the webpart

Create an empty Visual Studio Project.


Provide a website to debug the solution and select “Deploy as farm solution”.


Let us add a visual webpart in the solution, named SampleWebPart using New Item option in Add menu.


I have added two labels with the id as shown below.


It is time to add our resource files. For the same, we’ll map a resource folder

I will right click on the solution and select Add, where I will find SharePoint Mapped Folder.



After selecting resources in the proceeding screen, I will be able to see a resources folder in my solution.

In the Resources folder, I will create the resource file, by clicking Add Item.

Note the file name for the resource file: Resource.en-US.resx


Add some content to the resource file.


In the same way, create another resource file for the other language required.


Now we’ll do some programming to get our localization working.

Add following two lines in Page_Load event in SampleWebPart.ascx.cs.
Create a function named LoadResource along with an enum as shown below.


We are ready to go!

Just build and deploy the solution!

The preview on English Site


The Preview on Hindi Site:


Variations in SharePoint 2013

SharePoint 2013 is packed with many outstanding features. Variations, which were introduced way back in SharePoint 2007, still find its existence in SharePoint 2013.

The upgraded or the new feature in SharePoint 2013 is the ability to translate via Microsoft Translator.

For this particular context, we will learn how to make use of variations in your site.


A SharePoint 2013 site with publishing feature

Machine Translation Service already activated.

Instructions on how to activate the Variations

When it comes to activating the variations, we will achieve our purpose by following steps:

  • Create a source site, which will be in English
  • Create a target site, which will be derived from Source site, which is in English.
  • For the purpose of the document, we are having target site in Hindi.
Verify the Variations Settings

Go to Site Settings.
Under Site Collection Administration, click Variations Settings.


Variations Settings Page will show up.

Do the settings as per your need. For example, if you want to update the content on target site manually, you can set the options on this page accordingly.

Create the source variation

From the Site Collection Administration, click on Variation Labels

Following screen will be presented.


We will start with Adding a label.

Click New Label.

Now, we are in process of creating a source variation from where the content will be derived. To do so, select the locale as English (United States). This will act as our default source language.


Give any site location from where you want the source variation to be created. As already described on the page, you can also specify a top-level site by typing / in Variations home field.


You can specify a label name and description for this particular label if needed.


When the source variation is created, one can receive an e-mail notification (if configured) via the Label Contact field. You can enter any site member name here to direct the notification to the person.


Click OK

One thing I liked more about SharePoint 2013, it makes the user comfortable from each of its notifications!! 🙂

You will be comforted with following screen.


The creation of the source variation will depend on the timer job settings. You can modify them under the Central Administration -> Monitoring -> Review Job Definitions

As a result, your source variation will be created.


Creating target variations

Again, under Site Collection Administration, click on Variation Labels

Click New Label, you will be presented with following screen.


In my case, I am going for a Hindi target variation. So, I’ve selected the same in Locale.

Click Continue.

Enter Label Name, description and display name, if needed.

Click Continue.


It gives you an option to go for human translation, where you can create a XLIFF file and do the translation on the target site.

Click continue


On this particular page, you can go for the page update settings as per your requirement.

Click continue

Review the label settings and click finish.

As a result, as soon as your timer job completes, you will be able to see the following screen.


On the left pane, you are clearly able to see the two variations created.

For testing purpose, we will create a page on Source Site (English) and see if it is generated on Target Site (Hindi).

For the same, create a page on source site via the Gear menu.


Check in and publish the page.

Go to Variation labels from Site Collection Administration.

Click on Create hierarchies.

From the ribbon menu,

Click Publish, under which click Update all targets.


You will be able to see the above message.

As a result, you will be able to see a page in the target variation.


That’s all! 🙂