Exemple #1
0
 /// <summary>
 /// Begins an asynchronous request for translating the text to <paramref name="to"/> and auto detect which language the text is from.
 /// </summary>
 /// <param name="text">The content to translate.</param>
 /// <param name="to">The target language you want to translate to.</param>
 /// <param name="callback">The <see cref="AsyncCallback"/> delegate.</param>
 /// <param name="state">An object containing state information for this asynchronous request.</param>
 /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous request.</returns>
 public IAsyncResult BeginTranslateAndDetect(string text, string to, AsyncCallback callback, object state)
 {
     return(this.BeginTranslateAndDetect(text, to, TranslateFormat.GetDefault(), callback, state));
 }
Exemple #2
0
 /// <summary>
 /// Translate the text from <paramref name="from"/> to <paramref name="to"/>.
 /// </summary>
 /// <param name="text">The content to translate.</param>
 /// <param name="from">The language of the original text. You can set it as <c>Language.Unknown</c> to the auto detect it.</param>
 /// <param name="to">The target language you want to translate to.</param>
 /// <returns>The translate result.</returns>
 /// <exception cref="GoogleAPIException">Translate failed.</exception>
 /// <example>
 /// This is the c# code example.
 /// <code>
 /// 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.
 /// </code>
 /// </example>
 public string Translate(string text, string from, string to)
 {
     return(this.Translate(text, from, to, TranslateFormat.GetDefault()));
 }
Exemple #3
0
 /// <summary>
 /// Translate the text to <paramref name="to"/> and auto detect which language the text is from.
 /// </summary>
 /// <param name="text">The content to translate.</param>
 /// <param name="to">The target language you want to translate to.</param>
 /// <param name="from">The detected language of the original text.</param>
 /// <returns>The translate result.</returns>
 /// <exception cref="GoogleAPIException">Translate failed.</exception>
 /// <example>
 /// This is the c# code example.
 /// <code>
 /// string text = "Je t'aime.";
 /// string from;
 /// TranslateClient client = new TranslateClient(/* Enter the URL of your site here */);
 /// string translated = client.TranslateAndDetect(text, Language.English, out from);
 /// Language fromLanguage = from;
 /// Console.WriteLine("\"{0}\" is \"{1}\" in {2}", text, translated, fromLanguage);
 /// // "Je t'aime." is "I love you." in French.
 /// </code>
 /// </example>
 public string TranslateAndDetect(string text, string to, out string from)
 {
     return(this.TranslateAndDetect(text, to, TranslateFormat.GetDefault(), out from));
 }