Using Custom Logic to Send Out Content for Translation

You can call the <SendTranslationJobPipeline> pipeline to send out content for translation. This enables you to send out translation jobs using your own custom logic.

To call the pipeline:

You create an instance of the ClayTablet.SC.Pipelines.SendTranslationJobPipelineArgs class to pass to the <SendTranslationJobPipeline> pipeline as an argument.

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

public class SendTranslationJobPipelineArgs : PipelineArgs

{

public string JobName { get; set; }

public string SourceLanguage { get; set; }

public IEnumerable&lt;string&gt; TargetLanguages { get; set; }

public string SitecoreUser { get; set; }

public string TeamProfile { get; set; }

public string UselocalTM { get; set; }

public void AddItemsLatestVersionToTranslation(params string\[\] pathOrIdToItems) {}

public void AddItemsLatestPublishedVersionToTranslation(params string\[\] pathOrIdToItems) {}

public void AddItemVersionToTranslation(string pathOrId, int version) {}

public void SendCopyOnly() {}

public void SendToGenericProvider(string providerName, string jobDescription = "",

DateTime ? dueDate = null. string purchaseOrder = "", bool forQuote = false) {}

String purchaseOrder = "", bool forQuote = false, string serviceName = "") {}

public void SendToFreewayProvider(string providerName, string specialInstructions = "",

DateTime ? dueDate = null. string purchaseOrder = "", bool forQuote = false) {}

public void SetFreewayAnalysisCode(int level, string name, string value) {}

}

After instantiating this class, you perform the following steps:
  1. Specify the following information about the job:
  • job name
  • source language
  • target languages
  1. Add Sitecore items, and specify the source versions of those items to translate. You can choose to translate:
  • the latest version of items
  • the latest published version of items
  • choose a specific version for each item
  1. Specify the translation provider to which the Connector will the send the translation job, and provider-specific job metadata, such as:
  • job description or special instructions
  • due date
  • whether the job requires a quote
  • analysis codes (if the translation provider is Lionbridge Freeway)
  • the Sitecore user account for sending the job should be submitted
  • the team profile to which the job belongs
  • whether or not to use the local TM when sending out the job

The following code examples demonstrate how to send copy-only translation jobs, or how to send out jobs to a generic provider, to Lionbridge Freeway, using the ClayTablet.SC.Pipelines.SendTranslationJobPipelineArgs class:

static public void TestJobSendCopyOnly()

{

SendTranslationJobPipelineArgs args = new SendTranslationJobPipelineArgs();

args.JobName = "TestJobSendCopyOnly";

args.SourceLanguage = "en-US";

args.TargetLanguages = new string\[\] { "fr-FR", "de-DE" };

args.AddItemsLatestVersionToTranslation("path/to/item1", "id-of-item2", "path/to/item3");

args.AddItemsLatestPublishedVersionToTranslation("path/to/item4", "id-of-item5", "path/to/item6");

args.AddItemVersionToTranslation("path/to/item7", 2);

args.SendCopyOnly();

CorePipeline.Run("SendTranslationJobPipeline", args);

}

static public void TestJobSendToGenericProvider()

{

SendTranslationJobPipelineArgs args = new SendTranslationJobPipelineArgs();

args.JobName = "TestJobSendToGenericProvider";

args.SourceLanguage = "en-US";

args.TargetLanguages = new string\[\] { "fr-FR", "de-DE" };

args.AddItemsLatestVersionToTranslation("path/to/item1", "id-of-item2", "path/to/item3");

args.AddItemsLatestPublishedVersionToTranslation("path/to/item4", "id-of-item5", "path/to/item6");

args.AddItemVersionToTranslation("path/to/item7", 2);

args.SendToGenericProvider("MyGenericProvider", "Test job send to generice provider", DateTime.Now.AddDays(7), "PO1234", false);

CorePipeline.Run("SendTranslationJobPipeline", args);

}

static public void TestJobSendToFreewayProvider()

{

SendTranslationJobPipelineArgs args = new SendTranslationJobPipelineArgs();

args.JobName = "TestJobSendToFreewayProvider";

args.SourceLanguage = "en-US";

args.TargetLanguages = new string\[\] { "fr-FR", "de-DE" };

args.AddItemsLatestVersionToTranslation("path/to/item1", "id-of-item2", "path/to/item3");

args.AddItemsLatestPublishedVersionToTranslation("path/to/item4", "id-of-item5", "path/to/item6");

args.AddItemVersionToTranslation("path/to/item7", 2);

args.SendToFreewayProvider("MyFreewayProvider", "Special instructions for Freeway provider", DateTime.Now.AddDays(7), "PO1234", false);

args.SetFreewayAnalysisCode(1, "Region", "North America");

args.SetFreewayAnalysisCode(2, "Department", "Accounting");

args.SetFreewayAnalysisCode(3, "Severity", "Critical");

CorePipeline.Run("SendTranslationJobPipeline", args);

}