Skip to content

Instantly share code, notes, and snippets.

@chrismrgn
Last active January 2, 2016 00:39
Show Gist options
  • Save chrismrgn/8225441 to your computer and use it in GitHub Desktop.
Save chrismrgn/8225441 to your computer and use it in GitHub Desktop.
SDL Translation Manager API - Create Job
public void Translate(string identifiableObjectId, string owningRepositoryId)
{
if (!string.IsNullOrWhiteSpace(identifiableObjectId) && !string.IsNullOrWhiteSpace(owningRepositoryId))
{
//Create instance of TranslationJobManager
TranslationJobManager jobManager = new TranslationJobManager("DOMAIN\\USER");
//Create a PUSH job (job created at the source publication)
TranslationJob translationJob = jobManager.CreateJob("JobName", owningRepositoryId, TranslationJobType.PushJob);
//Get all target publications, based on the source publication
var targetPublications = jobManager.GetTranslationConfiguration(new Tridion.TranslationManager.DomainModel.Api.TcmUri(owningRepositoryId));
foreach (var targetconfiguration in targetPublications.TargetConfigurations)
{
translationJob.TargetPublicationUris.Add(targetconfiguration.ConfiguredItemUri);
}
//Add the item(s) to the translation job
translationJob.AddedItems.Add(new AddedItem(identifiableObjectId));
//Set the translation job's initial state
translationJob.State = TranslationJobState.ReadyForTranslation;
//Save job
translationJob.Save();
}
else
{
//invalid arguments
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment