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.

Content_1

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

Content_2

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

Content_3

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

Content_4

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.

Content_5

Content_6

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

Content_7

Add some content to the resource file.

Content_8

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

Content_9

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

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

Content_11

We are ready to go!

Just build and deploy the solution!

The preview on English Site

Content_12

The Preview on Hindi Site:

Content_13

Advertisements

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.

Prerequisites:

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.

img1

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.

img2

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.

img3

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.

img4

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

img5

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.

img6

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.

img7

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.

img8

Creating target variations

Again, under Site Collection Administration, click on Variation Labels

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

img9

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.

img10

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

img11

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.

img12

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.

img13

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.

img14

You will be able to see the above message.

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

img15

That’s all! 🙂