Code Samples, Simple Translation using CSOM, REST, and Machine Translation Services

Machine Translation Services is a powerful Shared Service Application in SharePoint Server 2013 that provides automation synchronous and asynchronous translation of documents, folders, and sites.  The code samples in this post provide simple examples of synchronous document translation using the Client Side Object Model in managed (C#) applications and Windows PowerShell in addition to accessing Machine Translation Services via REST.


The Client Side Object Model (CSOM) provides a rich alternative to earlier Web Services in providing an object-oriented system for interoperating with SharePoint data from a remote (client) machine.

The foundation of CSOM interop is the client context object which represents the current request context.  In the provided samples, it is represented in the C# example as:

new ClientContext(site)

or in the Windows PowerShell sample as:

New-Object Microsoft.SharePoint.Client.ClientContext($url) where the $url in this example is a parameter passed to the script.

Through this context you can obtain access to client objects to include site collections and their subordinates as represented in the above examples.

For example, in the sample scripts (download link below), the top-level site collection represents the new client context which is passed to the SyncTranslator class of the TranslationServices namespace as the Context property.

$context = New-Object Microsoft.SharePoint.Client.ClientContext($url)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
$context.Credentials = $credentials

$job = New-Object Microsoft.Office.Client.TranslationServices.SyncTranslator($context, $language)


REST or Representational State Transfer in the context of SharePoint 2013 development opens it to standard Web languages and technologies.  Technologies such as CSOM (as shown above) have been available to SharePoint over several releases; however, such APIs are limited to .NET applications and languages.  REST; however, enables accessing SharePoint capabilities and entities with standard Web languages such as JavaScript and preprocessor hypertext (PHP) in addition to any technology stack that supports REST.   One of the predominant benefits of REST is that it allows for limiting the footprint of Web applications, as such, reduces the barrier to entry to accessing cloud services and deploying applications whose target is such.

In SharePoint the REST service is implemented in client.svc contained within _vti_bin; however, through substitution _api is used and establishes the base Url for each endpoint.

The service Url of specific endpoints is appended to the base Url, in the sample code:

$request = [System.Net.WebRequest]::Create($url +"/_api/TranslationJob.EnumerateSupportedLanguages")

These samples are intended to illustrate how Windows PowerShell can be used to access cloud services through CSOM and REST.

Download the samples here:

CSOM (Windows PowerShell and C# Samples)

REST (Windows PowerShell Samples)

Introduction to Machine Translation Services in SharePoint 2013


SharePoint Server 2013 introduces several new service applications; among them is the new Machine Translation Service. The new Machine Translation Service enables you to reach more people with new cloud-based translation services capable of translating not only sites, but also their content. These services have a comprehensive set of APIs, REST, and CSOM support, so content can be pre-translated when needed, or translated on the fly by users—asynchronously, synchronously, or streaming.

This article provides a Machine Translation Services overview including to references to other useful Machine Translation Services resources.

Machine Translation Services provides machine translation; machine translation is the use of software to translate text from one natural language such as English to another, such as German basically substituting one word in one natural language to its corresponding word in another (see illustration).


In Machine Translation Services the actual translation process is performed by a cloud-hosted machine translation service where processed requests are submitted.


There are a variety of methods that can be used to submit translation requests discussed further in this article.

Architecturally the Machine Translation Service shares several components with Word Automation Services introduced in SharePoint Server 2010 including Timer Jobs, Document Queues, etc.  To that extent if you’re working with the server Object Model you’ll find similarities between Machine Translation Services and Word Automation Services including the Queue Manager/Schedule and Timer Job infrastructure which are responsible for the scheduling and adding of jobs to the Queue Database which also shares similarities with the Word Automation Services implementation in addition to the Application Manager which manages downloading files from content databases, creating and managing Application Workers, adding documents to Application Worker queues, and writing files back to a specified location.

The Application Worker Process; however, is unique to Machine Translation Services.


Machine Translation Services is capable of processing translation requests both synchronously and asynchronously.  Jobs submitted to the Machine Translation Service synchronously are processed when the translation service timer job (SharePoint Translation Services) executes on its configurable, default interval of 15 minutes. Conversely jobs submitted synchronously are instantly translated as the synchronous working queue is prioritized over the asynchronous working queue.

Asynchronous requests can be also be processed manually by running the SharePoint Translation Services Timer Job Definition through SharePoint 2013 Central Administration or optionally through Windows PowerShell (see example below):

$job = Get-SPTimerJob “SharePoint Translation Services”


For Object Model and REST-based code samples related to the Machine Translation Service see also

Provisioning and Configuring the Machine Translation Service


To provision and configure the Machine Translation Service your environment must meet the following minimum requirements:

The App Management Service is started.

Server-to-server and app authentication is configured.

The User Profile Service Application Proxy must be in the Default Proxy Group and the User Profile Service provisioned and configured.

Internet connectivity is available.

Provision and Configure the Machine Translation Service

To learn more about provisioning and configuring Machine Translation Service see also


Learn more about SharePoint Server 2013

IT Professionals

Create and Configure Machine Translation Services in SharePoint 2013


Machine Translation Services in SharePoint 2013

Server Object Model Code Samples

Client Side Object Model Code Samples


The Machine Translation Service is not running when it should be running (SharePoint 2013)

SharePoint Server 2013 Known Issues