All docs
V21.1
21.1
20.2
20.1
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

ITranslationService Interface

Defines the interface used to access a remote translation service.

Declaration

export interface ITranslationService

Remarks

The following code snippet demonstrates how to implement the ITranslationService interface and pass it as a parameter to the registerTranslationService function:

NOTE

The complete sample project How to Use the Microsoft Azure Translator Text API in Report Localization is available in the DevExpress Examples repository.

function BeforeDesignerRender(s, e) {
    DevExpress.Reporting.Designer.Localization.registerTranslationService("AzureCognitiveService", {
        onRequest: (texts, language) => {
            var data = { 'Texts': texts.map(text => ({ 'Text': text })), 'Language': language };
            return {
                type: "POST",
                url: '/Home/GetAzureTranslationService',
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                processData: true,
                data: JSON.stringify(data),
                error: function (xhr) {
                    DevExpress.ui.notify(xhr.statusText, "error", 500);
                }
            };
        },
        onResponse: (data) => {
            if (data.error && data.error.message) {
                DevExpress.ui.notify(data.error.message, "warning", 500);
                return [];
            }
            return data.map(function (item) {
                return item.translations[0].text
            });
        }
    });
}

Properties

onRequest Property

Specifies a function that is called before a HTTP request is sent.

Declaration

onRequest: (texts: string[], destinationLanguage: string) => JQueryAjaxSettings

Property Value

Type Description
(texts: string[], destinationLanguage: string) => JQueryAjaxSettings

Specifies a function that takes an array of strings and a string and returns a JQueryAjaxSettings object that is a set of key/value pairs that configure the Ajax request.

Remarks

The specified function should construct an Ajax request for a remote translation service.

onResponse Property

Specifies a function that is called when a HTTP response is received.

Declaration

onResponse: (result: any) => string[]

Property Value

Type Description
(result: any) => string[]

A function that takes a response result value and converts it to an array of strings.

Remarks

The specified function should convert information received from a remote translation service to an array of text strings.