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);
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. |
Return Value
A string representing the translated text
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);