Azure AI Translator – Translate Text from a String property in Optimizely CMS

In this article, I demonstrate how the text translation feature, offered by the Azure AI Text Translation service, can be used to translate text entered on a string property that is in the process of being published on the page within Optimizely CMS.

The Azure AI Text Translation is part of the AI Translator service. It uses neural machine translation technology to quickly and accurately translate text in real time across all supported languages. You can find the list of supported languages here.

The process is like this: when content is published on a string property, the AI text translation feature uses that content. It translates the content into the available language versions and puts the same text in each language version before publishing.

An example of this is shown in the screenshot below. The content on the Language Detection string property will be translated into Swedish, as this is the only other language version available for this page.

There is a screenshot below which demonstrates the code used to retrieve the translated text from the Azure AI Text Translation API

Response from the API via the Console

Azure AI Translator – Text Translation of a text field has completed

Detected languages of the input text: en with score: 0.93.
Text was translated to: ‘sv’ and the result is: ‘Vi besöker skådespelaren Sherry Bronfman i hennes minnesfyllda familjehem på Manhattans Upper West Side, som är till salu för första gången sedan 1971.’.

As mentioned in the API response, the translation service has created 1 translation. Once this is complete, the translated content is added and published for the specific language version in the CMS. A screenshot demonstrating this is shown below.