Documentation Center

Triggering translations

You can trigger a translation in two ways, from Workflow or from the Event System.

Triggering through Workflow

You can use the Translation Manager API to trigger translation from Workflow.

To work with the Translation Manager API from automatic C# workflow activities, use this code snippet to create a SessionAwareTmServiceClient object:
using (var tmClient = new SessionAwareTmServiceClient("TmBinaryEndpoint"))
{
    // [Do Translation Manager process]
}

In Workflow Designer, you can add an Automatic Activity. Set Script Type to C# and enter code directly in the dialog, such as the following example:

using (var tmClient = new SessionAwareTmServiceClient("TmBinaryEndpoint"))
{
  var job = tmClient.GetAllJobsOverview().FirstOrDefault();
  string jobName = job != null ? job.Title : "No job found";

  // Script for Automatic Activity Content Manager Workflow

  ActivityFinishData finishData = new ActivityFinishData(){ Message = "First job title is " + jobName };
  SessionAwareCoreServiceClient.FinishActivity(CurrentActivityInstance.Id, finishData, null);
}

Triggering from the Event System

You can trigger a translation from the Event System, allowing you to create translation jobs and send items for translation when an event system event is fired.

The Event System allows you to call custom code before and after actions occur within the Content Manager. The Event System raises (pre or post) events when actions occur within the Content Manager, such as saving a Component or publishing a Page. Pre-action events are triggered before a Content Manager action is performed, therefore the event may influence the action. Post-action events are triggered after a Content Manager action is performed.

Sample code to trigger push and pull translations from the Event System are available on the Tridion Sites installation media Translation Manager\samples directory.