Translate Method

[This is preliminary documentation and is subject to change.]

Converts a text string from one language to another.

 Syntax

C#

   string Translate(appId, text, from, to);
   

Dd576293.clear(en-us,MSDN.10).gif Parameters

Parameter Description

appId

A string representing the identifier of the calling application.

text

A string representing the text to translate.

from

A string representing the language code of the translation text.

to

A string representing the language code to translate the text into.

Dd576293.clear(en-us,MSDN.10).gif Return Value

A string representing the translated text

Dd576293.clear(en-us,MSDN.10).gif Example

C#

    string result; 
    try
    {
        TranslatorService.LanguageServiceClient client = new TranslatorService.LanguageServiceClient(); 
        result = client.Translate("myAppId", "Translate this text into German", "en", "de"); 
    } 
    catch (Exception ex) 
    { 
        // An exception may be thrown if the input text is not valid
        // An exception may be thrown if the to and from language codes are the same
        result = "Error: " + ex.Message; 
    } 
    Console.WriteLine(result);