|
| Google Translate API Documentation |
| TranslateClient..::.Translate Method (String, String, String) |
| TranslateClient Class Example See Also Send Feedback |
Translate the text from from to to.
Namespace:
Google.API.Translate
Assembly:
GoogleTranslateAPI (in GoogleTranslateAPI.dll) Version: 0.3.1.107 (0.3.1.107)
Syntax
| C# |
|---|
public string Translate( string text, string from, string to ) |
| Visual Basic (Declaration) |
|---|
Public Function Translate ( _ text As String, _ from As String, _ to As String _ ) As String |
| Visual C++ |
|---|
public: String^ Translate( String^ text, String^ from, String^ to ) |
Parameters
- text
- Type: System..::.String
The content to translate.
- from
- Type: System..::.String
The language of the original text. You can set it as Language.Unknown to the auto detect it.
- to
- Type: System..::.String
The target language you want to translate to.
Return Value
The translate result.
Examples
This is the c# code example.
CopyC#
string text = "我喜欢跑步。"; TranslateClient client = new TranslateClient(/* Enter the URL of your site here */); string translated = client.Translate(text, Language.ChineseSimplified, Language.English); Console.WriteLine(translated); // I like running.
Exceptions
| Exception | Condition |
|---|---|
| Google.API..::.GoogleAPIException | Translate failed. |
