Sitecore: Language versions

Introduction

Language version is one of the most important concepts in the Sitecore CMS in general and plays a crucial role within the framework of the XTM Connect – Sitecore (referred to below as “the XTM connector”) integration. A “language version” is simply a version of a translation of a particular content item for a particular language, stored in Sitecore.

When the Sitecore content is sent to XTM Cloud for translation, the XTM connector creates a language-specific version which it fills with the actual translation later, when the content is imported from XTM Cloud.


How do language versions work in the context of the XTM connector?

 

Content submitted to XTM Cloud

The most important thing to note is that the XTM connector creates a language version for a particular content item only when that item is sent to XTM Cloud for translation and NOT when the item is merely added to the translation queue. Naturally, the language versions are created for the target languages used for content submission.

At this point, the language version of this item, which is created for a particular target language, is assigned XTM Message: In translation status.

This status is caused by the XTM_Translation in progress checkbox, which is selected automatically in the XTM Connector section for this content item.

Lastly, as long as the submitted content item remains in XTM Cloud, i.e. its translation into a particular target language has not been imported back to the Sitecore CMS, the corresponding language version contains the text in the source language. This is because the language version cannot exist without any content whatsoever, so the original text acts as a sort of placeholder for the translation which is to be returned.

Content imported from XTM Cloud

Once the item’s translation into a particular target language has been imported back to the Sitecore CMS from XTM Cloud, the relevant language version of this item is assigned XTM Message: Translated status.

This status is caused by the XTM_Translation in progress checkbox, which is selected automatically in the XTM Connector section for this content item.

Lastly, the corresponding language version is filled with the actual translation.


Submitting an item to XTM Cloud for the same target language twice

Default mechanism

By default, the XTM connector is set to apply a certain restriction relating to language versions that are created within the framework of Sitecore content being submitted to XTM Cloud for translation.

If a particular content item is sent to XTM Cloud for translation into a specific target language, that item cannot be sent for translation into the same target language a second time until the first language version of this item has been imported back to the Sitecore CMS from XTM Cloud.

If a particular content item is sent to XTM Cloud for translation into a specific target language, that item cannot be sent for translation into the same target language a second time until the first language version of this item has been imported back to the Sitecore CMS from XTM Cloud.

In other words, a new content item’s language version for a particular target language cannot be created as long as the previous language version has the status In translation.

For example, if you try to send the item for the same target language again [in this case, German (Germany)], you will see the following information about this item in the log trace:

[2024.03.29 13:09:34] The item 'Sajzik MainItem {C81F9F60-00C8-4257-9772-62E91195A50A}' was NOT added - it is already in translation to 'de-DE'

This restriction was designed deliberately to prevent a particular content item from being sent for translation into the same target language multiple times. This might cause confusing and lead to the existence of multiple inconsistent translations of the same item at the same time, in the Sitecore CMS.

Do not show the option to send the same items for translation multiple times

In the XTM connector, you can change the mechanism described above. To do so, select the Do not show the option to send the same items for translation multiple times checkbox in the Sitecore Settings tab, in the XTM connector’s settings.

Use this checkbox to specify how XTM Connect – Sitecore Linguists (translation requesters) can add language versions to projects: they can either add one version after another or add several versions at once. Select the checkbox, or not, as required:

  • Checkbox selected: when an item is sent to XTM Cloud, for translation into several target languages, it will not be possible to also send the same item for translation in a new project. A Linguist will only be able to send the same item to XTM Cloud again once it has been finished and imported to Sitecore.

  • Checkbox not selected: when an item is sent to XTM Cloud, it can be included in many projects and translated into many languages at the same time.


Using PowerShell scripts to manage language versions

Introduction

In certain situations, when XTM Cloud projects are removed incorrectly, from the Sitecore CMS UI (see Sitecore: Process for removing/cancelling XTM Cloud projects from the CMS), relevant language versions might not be updated in accordance with the actions performed by the Sitecore user.

For example, imagine a project that consists of hundreds of Sitecore content items, each one of which has its own multiple language versions, depending on the number of target languages that this item has been translated into. If you remove the project incorrectly, as described in the article mentioned above, the project’s language versions will not be removed. Manual removal of those language versions would be a very tedious and time-consuming task.

This is where a couple of PowerShell scripts can be used to solve the problem. Make sure you have the Sitecore PowerShell Extension installed in your Sitecore CMS.

Scripts

For each script presented below, you just need to modify two variables:

  • -path → the path to the main Sitecore item (the script will also take into account all the main item’s sub-items).

  • -Language → a Sitecore language code, e.g. pl-PL.

Script for selecting the XTM_Translated checkbox in a language version

Foreach ($item in Get-ChildItem -path "/PATH/TO/MAIN/ITEM" -Language "LANGUAGE-CODE" -Recurse | Where-Object { $_.Fields['XTM_Translation in progress'] -ne $null }) { $item.Editing.BeginEdit(); $item.Fields['__Workflow state'].Value = "{33887AC8-F047-499B-A4D4-BF27E78EBCD3}"; $item.Fields['__Workflow'].Value = "{011178AC-321A-4C3E-8E27-5B92DB57E062}"; $item.Fields['XTM_Translation in progress'].Value = "0"; $item.Fields['XTM_Translated'].Value = "1"; $item.Editing.EndEdit(); Write-Output "Updated item: " $item.Version.Number $item.Name $item.Id.Guid.Guid }

Script for deselecting the XTM_Translation in progress checkbox in a language version

Foreach ($item in Get-ChildItem -path "/PATH/TO/MAIN/ITEM" -Language "LANGUAGE-CODE" -Recurse | Where-Object { $_.Fields['XTM_Translation in progress'] -ne $null }) { $item.Editing.BeginEdit(); $item.Fields['XTM_Translation in progress'].Value = "0"; $item.Editing.EndEdit(); Write-Output "Updated item: " $item.Version.Number $item.Name $item.Id.Guid.Guid }

Script for deleting a language version