SingleDocumentTranslationClient.TranslateAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| TranslateAsync(String, DocumentTranslateContent, String, String, String, Nullable<Boolean>, Nullable<Boolean>, CancellationToken) |
Submit a single document translation request to the Document Translation service. |
| TranslateAsync(String, RequestContent, String, String, String, String, Nullable<Boolean>, Nullable<Boolean>, RequestContext) |
[Protocol Method] Use this API to submit a single translation request to the Document Translation Service.
|
TranslateAsync(String, DocumentTranslateContent, String, String, String, Nullable<Boolean>, Nullable<Boolean>, CancellationToken)
Submit a single document translation request to the Document Translation service.
public virtual System.Threading.Tasks.Task<Azure.Response<BinaryData>> TranslateAsync(string targetLanguage, Azure.AI.Translation.Document.DocumentTranslateContent documentTranslateContent, string sourceLanguage = default, string category = default, string deploymentName = default, bool? allowFallback = default, bool? translateTextWithinImage = default, System.Threading.CancellationToken cancellationToken = default);
abstract member TranslateAsync : string * Azure.AI.Translation.Document.DocumentTranslateContent * string * string * string * Nullable<bool> * Nullable<bool> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<BinaryData>>
override this.TranslateAsync : string * Azure.AI.Translation.Document.DocumentTranslateContent * string * string * string * Nullable<bool> * Nullable<bool> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<BinaryData>>
Public Overridable Function TranslateAsync (targetLanguage As String, documentTranslateContent As DocumentTranslateContent, Optional sourceLanguage As String = Nothing, Optional category As String = Nothing, Optional deploymentName As String = Nothing, Optional allowFallback As Nullable(Of Boolean) = Nothing, Optional translateTextWithinImage As Nullable(Of Boolean) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of BinaryData))
Parameters
- targetLanguage
- String
Specifies the language of the output document. The target language must be one of the supported languages included in the translation scope. For example if you want to translate the document in German language, then use targetLanguage=de
- documentTranslateContent
- DocumentTranslateContent
Document Translate Request Content.
- sourceLanguage
- String
Specifies source language of the input document. If this parameter isn't specified, automatic language detection is applied to determine the source language. For example if the source document is written in English, then use sourceLanguage=en
- category
- String
A string specifying the category (domain) of the translation. This parameter is used to get translations from a customized system built with Custom Translator. Add the Category ID from your Custom Translator project details to this parameter to use your deployed customized system. Default value is: general.
- deploymentName
- String
Deployment name of the custom translation model for the translation request.
Specifies that the service is allowed to fall back to a general system when a custom system doesn't exist. Possible values are: true (default) or false.
Optional boolean parameter to translate text within an image in the document.
- cancellationToken
- CancellationToken
The cancellation token to use.
Returns
Exceptions
targetLanguage or documentTranslateContent is null.
Remarks
Use this API to submit a single translation request to the Document Translation Service.
Applies to
TranslateAsync(String, RequestContent, String, String, String, String, Nullable<Boolean>, Nullable<Boolean>, RequestContext)
[Protocol Method] Use this API to submit a single translation request to the Document Translation Service.
- 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(string targetLanguage, Azure.Core.RequestContent content, string contentType, string sourceLanguage = default, string category = default, string deploymentName = default, bool? allowFallback = default, bool? translateTextWithinImage = default, Azure.RequestContext context = default);
abstract member TranslateAsync : string * Azure.Core.RequestContent * string * string * string * string * Nullable<bool> * Nullable<bool> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.TranslateAsync : string * Azure.Core.RequestContent * string * string * string * string * Nullable<bool> * Nullable<bool> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function TranslateAsync (targetLanguage As String, content As RequestContent, contentType As String, Optional sourceLanguage As String = Nothing, Optional category As String = Nothing, Optional deploymentName As String = Nothing, Optional allowFallback As Nullable(Of Boolean) = Nothing, Optional translateTextWithinImage As Nullable(Of Boolean) = Nothing, Optional context As RequestContext = Nothing) As Task(Of Response)
Parameters
- targetLanguage
- String
Specifies the language of the output document. The target language must be one of the supported languages included in the translation scope. For example if you want to translate the document in German language, then use targetLanguage=de
- content
- RequestContent
The content to send as the body of the request.
- contentType
- String
The contentType to use which has the multipart/form-data boundary.
- sourceLanguage
- String
Specifies source language of the input document. If this parameter isn't specified, automatic language detection is applied to determine the source language. For example if the source document is written in English, then use sourceLanguage=en
- category
- String
A string specifying the category (domain) of the translation. This parameter is used to get translations from a customized system built with Custom Translator. Add the Category ID from your Custom Translator project details to this parameter to use your deployed customized system. Default value is: general.
- deploymentName
- String
Deployment name of the custom translation model for the translation request.
Specifies that the service is allowed to fall back to a general system when a custom system doesn't exist. Possible values are: true (default) or false.
Optional boolean parameter to translate text within an image in the document.
- 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
targetLanguage, content or contentType is null.
targetLanguage or contentType is an empty string, and was expected to be non-empty.
Service returned a non-success status code.