Using Custom Logic to Populate the Translation Queue

You can call the <SendToTranslationQueuePipeline> pipeline to put Sitecore items into the Translation Queue. The items are displayed in the queue only for the Context.User.

Prerequisite:

You must set the Context.User to a user with Sitecore access. This must be the user who will review and send out the queued items. If you do not set the context user, then the default user is sitecore\Anonymous, which prevents the items from being displayed in the queue.

To call the pipeline:

You create an instance of the ClayTablet.SC.Pipelines.SendToTranslationQueuePipelineArgs class to pass to the pipeline as argument.

The SendToTranslationQueuePipelineArgs class is defined in ClayTablet.SC.dll as:

public class SendToTranslationQueuePipelineArgs : PipelineArgs

{

public String SourceLanguage { get; set; }

public String\[\] TargetLanguages { get; set; }

public List&lt;String&gt; ItemIds { get; }

public int ItemsQueued { get; }

}

This class enables you to specify the source language and target languages for the items, and add Sitecore item ID into the ItemIds list. The Connector uses the latest source version of the items. When the Connector sends out content for translation from Translation Queue, it creates new target versions for these items. After calling the pipeline, you can use the ItemsQueued property to check how many Sitecore items are actually added to the Translation Queue.

The following is sample code for calling the pipeline:

static public int SendToTranslationQueue(string sourceLang, string[] targetLangs, string[] itemIds)

{

SendToTranslationQueuePipelineArgs args = new SendToTranslationQueuePipelineArgs();

args.SourceLanguage = sourceLang;

args.TargetLanguages = targetLangs;

args.ItemIds.AddRange(itemIds);

CorePipeline.Run("SendToTranslationQueuePipeline", args);

return args.ItemsQueued;

}