TextTranslationClient.GetSupportedLanguagesAsync Method

Definition

Overloads

GetSupportedLanguagesAsync(String, String, String, Nullable<ETag>, RequestContext)

[Protocol Method] Gets the set of languages currently supported by other operations of the Translator.

GetSupportedLanguagesAsync(String, String, String, Nullable<ETag>, CancellationToken)

Gets the set of languages currently supported by other operations of the Translator.

GetSupportedLanguagesAsync(String, String, String, Nullable<ETag>, RequestContext)

Source:
TextTranslationClient.cs

[Protocol Method] Gets the set of languages currently supported by other operations of the Translator.

public virtual System.Threading.Tasks.Task<Azure.Response> GetSupportedLanguagesAsync (string clientTraceId, string scope, string acceptLanguage, Azure.ETag? ifNoneMatch, Azure.RequestContext context);
abstract member GetSupportedLanguagesAsync : string * string * string * Nullable<Azure.ETag> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GetSupportedLanguagesAsync : string * string * string * Nullable<Azure.ETag> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GetSupportedLanguagesAsync (clientTraceId As String, scope As String, acceptLanguage As String, ifNoneMatch As Nullable(Of ETag), context As RequestContext) As Task(Of Response)

Parameters

clientTraceId
String

A client-generated GUID to uniquely identify the request.

scope
String

A comma-separated list of names defining the group of languages to return. Allowed group names are: translation, transliteration and dictionary. If no scope is given, then all groups are returned, which is equivalent to passing scope=translation,transliteration,dictionary. To decide which set of supported languages is appropriate for your scenario, see the description of the response object.

acceptLanguage
String

The language to use for user interface strings. Some of the fields in the response are names of languages or names of regions. Use this parameter to define the language in which these names are returned. The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value fr to request names in French or use the value zh-Hant to request names in Chinese Traditional. Names are provided in the English language when a target language is not specified or when localization is not available.

ifNoneMatch
Nullable<ETag>

Passing the value of the ETag response header in an If-None-Match field will allow the service to optimize the response. If the resource has not been modified, the service will return status code 304 and an empty response body.

context
RequestContext

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

Returns

The response returned from the service.

Exceptions

Service returned a non-success status code.

Examples

This sample shows how to call GetSupportedLanguagesAsync and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TextTranslationClient client = new TextTranslationClient(endpoint);

Response response = await client.GetSupportedLanguagesAsync(null, null, null, null, null);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.ToString());

This sample shows how to call GetSupportedLanguagesAsync with all parameters and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TextTranslationClient client = new TextTranslationClient(endpoint);

Response response = await client.GetSupportedLanguagesAsync("<clientTraceId>", "<scope>", "<acceptLanguage>", new ETag("<ifNoneMatch>"), null);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("translation").GetProperty("<key>").GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("translation").GetProperty("<key>").GetProperty("nativeName").ToString());
Console.WriteLine(result.GetProperty("translation").GetProperty("<key>").GetProperty("dir").ToString());
Console.WriteLine(result.GetProperty("transliteration").GetProperty("<key>").GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("transliteration").GetProperty("<key>").GetProperty("nativeName").ToString());
Console.WriteLine(result.GetProperty("transliteration").GetProperty("<key>").GetProperty("scripts")[0].GetProperty("toScripts")[0].GetProperty("code").ToString());
Console.WriteLine(result.GetProperty("transliteration").GetProperty("<key>").GetProperty("scripts")[0].GetProperty("toScripts")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("transliteration").GetProperty("<key>").GetProperty("scripts")[0].GetProperty("toScripts")[0].GetProperty("nativeName").ToString());
Console.WriteLine(result.GetProperty("transliteration").GetProperty("<key>").GetProperty("scripts")[0].GetProperty("toScripts")[0].GetProperty("dir").ToString());
Console.WriteLine(result.GetProperty("transliteration").GetProperty("<key>").GetProperty("scripts")[0].GetProperty("code").ToString());
Console.WriteLine(result.GetProperty("transliteration").GetProperty("<key>").GetProperty("scripts")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("transliteration").GetProperty("<key>").GetProperty("scripts")[0].GetProperty("nativeName").ToString());
Console.WriteLine(result.GetProperty("transliteration").GetProperty("<key>").GetProperty("scripts")[0].GetProperty("dir").ToString());
Console.WriteLine(result.GetProperty("dictionary").GetProperty("<key>").GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("dictionary").GetProperty("<key>").GetProperty("nativeName").ToString());
Console.WriteLine(result.GetProperty("dictionary").GetProperty("<key>").GetProperty("dir").ToString());
Console.WriteLine(result.GetProperty("dictionary").GetProperty("<key>").GetProperty("translations")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("dictionary").GetProperty("<key>").GetProperty("translations")[0].GetProperty("nativeName").ToString());
Console.WriteLine(result.GetProperty("dictionary").GetProperty("<key>").GetProperty("translations")[0].GetProperty("dir").ToString());
Console.WriteLine(result.GetProperty("dictionary").GetProperty("<key>").GetProperty("translations")[0].GetProperty("code").ToString());

Applies to

GetSupportedLanguagesAsync(String, String, String, Nullable<ETag>, CancellationToken)

Source:
TextTranslationClient.cs

Gets the set of languages currently supported by other operations of the Translator.

public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.Translation.Text.GetSupportedLanguagesResult>> GetSupportedLanguagesAsync (string clientTraceId = default, string scope = default, string acceptLanguage = default, Azure.ETag? ifNoneMatch = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetSupportedLanguagesAsync : string * string * string * Nullable<Azure.ETag> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.Translation.Text.GetSupportedLanguagesResult>>
override this.GetSupportedLanguagesAsync : string * string * string * Nullable<Azure.ETag> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.Translation.Text.GetSupportedLanguagesResult>>
Public Overridable Function GetSupportedLanguagesAsync (Optional clientTraceId As String = Nothing, Optional scope As String = Nothing, Optional acceptLanguage As String = Nothing, Optional ifNoneMatch As Nullable(Of ETag) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of GetSupportedLanguagesResult))

Parameters

clientTraceId
String

A client-generated GUID to uniquely identify the request.

scope
String

A comma-separated list of names defining the group of languages to return. Allowed group names are: translation, transliteration and dictionary. If no scope is given, then all groups are returned, which is equivalent to passing scope=translation,transliteration,dictionary. To decide which set of supported languages is appropriate for your scenario, see the description of the response object.

acceptLanguage
String

The language to use for user interface strings. Some of the fields in the response are names of languages or names of regions. Use this parameter to define the language in which these names are returned. The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value fr to request names in French or use the value zh-Hant to request names in Chinese Traditional. Names are provided in the English language when a target language is not specified or when localization is not available.

ifNoneMatch
Nullable<ETag>

Passing the value of the ETag response header in an If-None-Match field will allow the service to optimize the response. If the resource has not been modified, the service will return status code 304 and an empty response body.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Examples

This sample shows how to call GetSupportedLanguagesAsync.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TextTranslationClient client = new TextTranslationClient(endpoint);

Response<GetSupportedLanguagesResult> response = await client.GetSupportedLanguagesAsync();

This sample shows how to call GetSupportedLanguagesAsync with all parameters.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TextTranslationClient client = new TextTranslationClient(endpoint);

Response<GetSupportedLanguagesResult> response = await client.GetSupportedLanguagesAsync(clientTraceId: "<clientTraceId>", scope: "<scope>", acceptLanguage: "<acceptLanguage>", ifNoneMatch: new ETag("<ifNoneMatch>"));

Applies to