Partilhar via


TextTranslationClient.GetSupportedLanguages Method

Definition

Overloads

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

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

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

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

GetSupportedLanguages(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 Azure.Response GetSupportedLanguages (string clientTraceId, string scope, string acceptLanguage, Azure.ETag? ifNoneMatch, Azure.RequestContext context);
abstract member GetSupportedLanguages : string * string * string * Nullable<Azure.ETag> * Azure.RequestContext -> Azure.Response
override this.GetSupportedLanguages : string * string * string * Nullable<Azure.ETag> * Azure.RequestContext -> Azure.Response
Public Overridable Function GetSupportedLanguages (clientTraceId As String, scope As String, acceptLanguage As String, ifNoneMatch As Nullable(Of ETag), context As RequestContext) As 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 GetSupportedLanguages and parse the result.

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

Response response = client.GetSupportedLanguages(null, null, null, null, null);

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

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

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

Response response = client.GetSupportedLanguages("<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

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

Source:
TextTranslationClient.cs

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

public virtual Azure.Response<Azure.AI.Translation.Text.GetSupportedLanguagesResult> GetSupportedLanguages (string clientTraceId = default, string scope = default, string acceptLanguage = default, Azure.ETag? ifNoneMatch = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetSupportedLanguages : string * string * string * Nullable<Azure.ETag> * System.Threading.CancellationToken -> Azure.Response<Azure.AI.Translation.Text.GetSupportedLanguagesResult>
override this.GetSupportedLanguages : string * string * string * Nullable<Azure.ETag> * System.Threading.CancellationToken -> Azure.Response<Azure.AI.Translation.Text.GetSupportedLanguagesResult>
Public Overridable Function GetSupportedLanguages (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 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 GetSupportedLanguages.

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

Response<GetSupportedLanguagesResult> response = client.GetSupportedLanguages();

This sample shows how to call GetSupportedLanguages with all parameters.

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

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

Applies to