Home » Microsoft » 70-489 » Which code segment should you use?
You create a publishing site collection and configure it for anonymous use. The Machine Translation Service (MTS) application is configured and available.
New pages in the site collection must be translated immediately to other languages by using the SharePoint Variations feature and the MTS application.
You need to configure the MTS application to perform translations synchronously.
Which code segment should you use?
A.
B.
C.
D.
Correct Answer: B
Explanation/Reference:
The following code shows how to translate a single file synchronously.
SPServiceContext sc = SPServiceContext.GetContext(new SPSite(site));
SyncTranslator job = new SyncTranslator(sc, CultureInfo.GetCultureInfo(jobCulture));
TranslationItemInfo itemInfo = job.Translate(input, output);
The following code shows how to translate a single file asynchronously.
SPServiceContext sc = SPServiceContext.GetContext(new SPSite(site));
TranslationJob job = new TranslationJob(sc, CultureInfo.GetCultureInfo(culture));
job.AddFile(input, output);
job.Start();
To translate a single file asynchronously:
var asyncJob;
var clientContext = new SP.ClientContext("serverRelativeUrl");
var contextSite = clientContext.get_site();
asyncJob = SP.Translation.TranslationJob.newObject(clientContext, "cultureID");
asyncJob.set_outputSaveBehavior(SP.Translation.SaveBehavior.alwaysOverwrite);
Reference: Machine Translation Services in SharePoint 2013