TranslatorLibrary.GetLanguageNamesAsync(string, string) Method

Bing
 

The GetLanguageNamesAsync(string, string[]) method retrieves the displayable “friendly” names of languages for an array of language codes, in the language specified in the locale parameter

Published date: October 21, 2013

public IAsyncAction GetLanguageNamesAsync(string locale, string[] languageCodes)

locale

Type: System.String  

Description: Required. A string representing a combination of an ISO 639 two-letter lowercase culture code associated with a language and an ISO 3166 two-letter uppercase subculture code to localize the language names or a ISO 639 lowercase culture code by itself.

languageCodes

Type: System.String[]

Description: Required. A string array representing the ISO 639-1 language codes to retrieve the friendly name for.

Type: System.String[]

The list of languages names supported by the Translator Service, localized into the language specified in locale and culture code.

This method is primarily used to render a list of language for user to choose from, as a language to translate from or to. You can pass the result of the GetLanguagesAsync(string, string[]) method directly as the languageCodes parameter.

Example

The following example retrieves the friendly names of language codes in an array, as it was received from the GetLanguagesAsync method.

this.LangTextBox.Text = string.Join(
    ",", (await this.Translator2.TranslatorApi.GetLanguageNamesAsync(
    "en", new string[] { lang })).Languages);

Example

The following example retrieves the friendly names of language codes in an array, as it was received from the GetLanguagesAsync method, and writes them to a UI element named 'languagenames'.

// Initialize a TranslatorLibrary instance.
var translatorApi = Bing.Translator.TranslatorLibrary("CLIENTID", "CLIENTSECRET");

// Get the list of language names and write them to a UI element with an ID of 'languagenames'.
translatorApi.getLanguageNamesAsync("en", [ "es", "fr" ]).then(function (result) {
    document.getElementById('languagenames').innerText = result.languages;
});


Requirements

Minimum Supported Client

Windows 8.1

Required Extensions

Bing Translator Control

Namespace

Bing.Translator

Show: