Friday, 31 March 2017

Translating Sitecore Client

Translating Sitecore Client to another language is not so tough issue. Sitecore comes with a pretty clean solution here. In this article we will use Sitecore 8.2 Update-2.

There are some ready-to-install client translations at Sitecore download site (section "Client Translations"): https://dev.sitecore.net/Downloads/Sitecore_Experience_Platform/82/Sitecore_Experience_Platform_82_Update2.aspx. The choice is not too big, there are only for Danish, German and Japanese. Fortunately, we can create our own client translation.

Preparation

First of all, we need to install language in Sitecore on specific database. We will start with core, where most of our client translations are kept. Let's go to Desktop and switch to Core db. After that let's go to Control Panel. Here we should add new language and set language code for it. In my example I will add Polish language

Sitecore - Control Panel - Add new Language

I'm leaving all steps with default values, so my Polish language code will be "pl-PL". After that we can check it in Content Editor under /sitecore/system/Languages:

Sitecore - Content Editor - Languages

Exporting language file

At this point we need to have a file that will be our source for translation. In other words, we need to export language file from one of existing languages in Sitecore. To achieve that, let's go again to Control Panel. There should be Core database selected as earlier. In Control Panel click on the Export languages and select the language you want to base your translation on:

Sitecore - Control Panel - Export language

After clicking next, you can choose which branch to export. For making translations select sitecore root item:

Sitecore - Control Panel - Export language - select item

After that you will be prompted for location of generated file. In the end Sitecore will process all items and language xml file will be generated.

Preparing language file

Let's take a quick glimpse to the exported language file. You can see that this is just xml file with <phrase> elements. Each that element represents single field of item and contains attributes like:
  • path - path of the item
  • itemid - id of the item
  • key - key name of field
  • fieldid - name of the field
  • updated - date of field update
Inside <phrase>, there is another xml element named after the language code. It surrounds the field value we will translate.

Sitecore - Exported language file

Next thing is to replace language elements with our destination language. In my case it will be pl-PL. The easiest and fastest way will be use some text editor and globally replace:
  • <en> to  <pl-PL>
  • </en> to  </pl-PL>

Replace globally


And that's it! File is prepared for sending to some translation services. They just need to know what they have to translate:

<phrase path="/sitecore/client/Speak/Layouts/Renderings/Common" key="Common" itemid="{1F2A25A4-A532-4E9B-9942-1FA6F10F61B0}" fieldid="__Short description" updated="20130814T120321Z">
    <pl-PL>Common controls like buttons, input fields, and lists.</pl-PL>
 </phrase>
In my case it should be translated to:

<phrase path="/sitecore/client/Speak/Layouts/Renderings/Common" key="Common" itemid="{1F2A25A4-A532-4E9B-9942-1FA6F10F61B0}" fieldid="__Short description" updated="20130814T120321Z">
    <pl-PL>Wspólne kontrolki, takie jak przyciski, pola wprowadzania, czy listy.</pl-PL>
 </phrase>

Just trust me ;)

Importing prepared language file

As we have our language file translated we can import it to Sitecore. Before that, it is highly recommended to backup processed database - in our case Core database. After our backup is done we can import our translation file. To achieve that let's go to Control Panel and click Import languages:

Sitecore - Control Panel - Import languages

Then we need to upload our prepared xml file (or put it somewhere in webroot of our Sitecore). After selecting the file, Sitecore should recognize what language we are importing.

Sitecore - Control Panel - Import languages

Then we need to select the database which items we were translating - for us it is the Core database.

Sitecore - Control Panel - Import languages

After a while import will be finished.

Configuring Sitecore client language

After the import we can use our language. One of the ways is to set globally Sitecore client language in the Control Panel. In the My settings section, there is a Region and languages options link. It opens window where we can set viewing formats and Display language:

Sitecore - Control Panel - Region and languages options

After setting it, you will be prompted to refresh browser window - and you can enjoy the translated Sitecore! More info on installing translations can be found on Sitecore documentation: https://dev.sitecore.net/Downloads/Sitecore_Experience_Platform/82/~/link.aspx?_id=D72CBF8CE581436CBBCAEE896C8646F7&_z=z

Another way is to set the language just for the user. We can find it in the User Manager by clicking Edit on selected user and setting Client language on Language settings tab.

Sitecore - User Manager - Language settings

Translating master database

We were translating only core items, but we can also translate master database items. I might not have sense for all Sitecore items, but for short descriptions of main items like content, layouts, templates, etc.


Happy translating!

Share it:

Radosław Kozłowski - Senior Sitecore Developer Radosław Kozłowski

Author & Editor

Senior Sitecore Developer and Team Leader with over 4 years experience

0 comments:

Post a Comment