TextTranslationClient.TranslateAsync Method

Definition

Overloads

Name Description
TranslateAsync(String, String, String, CancellationToken)

Translate Text.

TranslateAsync(String, IEnumerable<String>, String, CancellationToken)

Translate Text.

TranslateAsync(RequestContent, String, RequestContext)

[Protocol Method] Translate Text

  • This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
TranslateAsync(IEnumerable<TranslateInputItem>, CancellationToken)

Translate Text.

TranslateAsync(TranslateInputItem, CancellationToken)

Translate Text.

TranslateAsync(String, String, String, CancellationToken)

Source:
TextTranslationClient.cs
Source:
TextTranslationClient.cs

Translate Text.

public virtual System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.AI.Translation.Text.TranslatedTextItem>>> TranslateAsync(string targetLanguage, string text, string sourceLanguage = default, System.Threading.CancellationToken cancellationToken = default);
abstract member TranslateAsync : string * string * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.AI.Translation.Text.TranslatedTextItem>>>
override this.TranslateAsync : string * string * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.AI.Translation.Text.TranslatedTextItem>>>
Public Overridable Function TranslateAsync (targetLanguage As String, text As String, Optional sourceLanguage As String = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of IReadOnlyList(Of TranslatedTextItem)))

Parameters

targetLanguage
String

Specifies the language of the output text. The target language must be one of the supported languages included in the translation scope. For example, use to=de to translate to German. It's possible to translate to multiple languages simultaneously by repeating the parameter in the query string. For example, use to=de&to=it to translate to German and Italian.

text
String

Text to be translated.

sourceLanguage
String

Specifies the language of the input text. Find which languages are available to translate from by looking up supported languages using the translation scope. If the from parameter isn't specified, automatic language detection is applied to determine the source language.

You must use the from parameter rather than autodetection when using the dynamic dictionary feature. Note: the dynamic dictionary feature is case-sensitive.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

targetLanguage or text is null.

Applies to

TranslateAsync(String, IEnumerable<String>, String, CancellationToken)

Source:
TextTranslationClient.cs
Source:
TextTranslationClient.cs

Translate Text.

public virtual System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.AI.Translation.Text.TranslatedTextItem>>> TranslateAsync(string targetLanguage, System.Collections.Generic.IEnumerable<string> content, string sourceLanguage = default, System.Threading.CancellationToken cancellationToken = default);
abstract member TranslateAsync : string * seq<string> * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.AI.Translation.Text.TranslatedTextItem>>>
override this.TranslateAsync : string * seq<string> * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.AI.Translation.Text.TranslatedTextItem>>>
Public Overridable Function TranslateAsync (targetLanguage As String, content As IEnumerable(Of String), Optional sourceLanguage As String = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of IReadOnlyList(Of TranslatedTextItem)))

Parameters

targetLanguage
String

Specifies the language of the output text. The target language must be one of the supported languages included in the translation scope. For example, use to=de to translate to German. It's possible to translate to multiple languages simultaneously by repeating the parameter in the query string. For example, use to=de&to=it to translate to German and Italian.

content
IEnumerable<String>

Array of the text to be translated.

sourceLanguage
String

Specifies the language of the input text. Find which languages are available to translate from by looking up supported languages using the translation scope. If the from parameter isn't specified, automatic language detection is applied to determine the source language.

You must use the from parameter rather than autodetection when using the dynamic dictionary feature. Note: the dynamic dictionary feature is case-sensitive.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

targetLanguage or content is null.

Applies to

TranslateAsync(RequestContent, String, RequestContext)

Source:
TextTranslationClient.cs
Source:
TextTranslationClient.cs

[Protocol Method] Translate Text

  • This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
public virtual System.Threading.Tasks.Task<Azure.Response> TranslateAsync(Azure.Core.RequestContent content, string clientTraceId = default, Azure.RequestContext context = default);
abstract member TranslateAsync : Azure.Core.RequestContent * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.TranslateAsync : Azure.Core.RequestContent * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function TranslateAsync (content As RequestContent, Optional clientTraceId As String = Nothing, Optional context As RequestContext = Nothing) As Task(Of Response)

Parameters

content
RequestContent

The content to send as the body of the request.

clientTraceId
String

A client-generated GUID to uniquely identify the request.

context
RequestContext

The request options, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The response returned from the service.

Exceptions

content is null.

Service returned a non-success status code.

Applies to

TranslateAsync(IEnumerable<TranslateInputItem>, CancellationToken)

Source:
TextTranslationClient.cs
Source:
TextTranslationClient.cs

Translate Text.

public virtual System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.AI.Translation.Text.TranslatedTextItem>>> TranslateAsync(System.Collections.Generic.IEnumerable<Azure.AI.Translation.Text.TranslateInputItem> inputs, System.Threading.CancellationToken cancellationToken = default);
abstract member TranslateAsync : seq<Azure.AI.Translation.Text.TranslateInputItem> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.AI.Translation.Text.TranslatedTextItem>>>
override this.TranslateAsync : seq<Azure.AI.Translation.Text.TranslateInputItem> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.AI.Translation.Text.TranslatedTextItem>>>
Public Overridable Function TranslateAsync (inputs As IEnumerable(Of TranslateInputItem), Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of IReadOnlyList(Of TranslatedTextItem)))

Parameters

inputs
IEnumerable<TranslateInputItem>

Defines the inputs of the translation request.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

inputs is null.

Applies to

TranslateAsync(TranslateInputItem, CancellationToken)

Source:
TextTranslationClient.cs
Source:
TextTranslationClient.cs

Translate Text.

public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.Translation.Text.TranslatedTextItem>> TranslateAsync(Azure.AI.Translation.Text.TranslateInputItem input, System.Threading.CancellationToken cancellationToken = default);
abstract member TranslateAsync : Azure.AI.Translation.Text.TranslateInputItem * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.Translation.Text.TranslatedTextItem>>
override this.TranslateAsync : Azure.AI.Translation.Text.TranslateInputItem * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.Translation.Text.TranslatedTextItem>>
Public Overridable Function TranslateAsync (input As TranslateInputItem, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of TranslatedTextItem))

Parameters

input
TranslateInputItem

Defines the input of the translation request.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

input is null.

Applies to