title: Translate text in other languages in asp.net C# web application
body: <p>I want to translate text in Indian languages. I have gone through many articles but can not understand clearly how to do so. I have also seen some articles on google translator but none of them provide guide to use it in code.
  Please guide me how can I do so. Do I need to add fonts for all languages in my application?  </p>
  
  <p>I have pasted the following code and now getting error. Can't understand what is that error.
  The error is "Index and length must refer to a location within the string.
  Parameter name: length".</p>
  
  <p>Below is my code.</p>
  
  <pre><code> public string TranslateText(string input, string languagePair)
   {
      string url = String.Format("http://www.google.com/translate_t?hl=en&amp;ie=UTF8&amp;text={0}&amp;langpair={1}", input, languagePair);
      WebClient webClient = new WebClient();
      webClient.Encoding = System.Text.Encoding.UTF8;
      string result = webClient.DownloadString(url);
      result = result.Substring(result.IndexOf("id=result_box") + 22, result.IndexOf("id=result_box") + 500);
      result = result.Substring(0, result.IndexOf("&lt;/div"));
      return result;
  }
  protected void btnTranslate_Click(object sender, EventArgs e)
  {
      string convertTo="en|"+ddlLanguages.SelectedValue;
      txtTarget.Text = TranslateText(txtLanguage.Text, convertTo);
  }
  </code></pre>
  
  <p>ID of both the textboxes are "txtLanguage" for source language and "txtTarget" for target language.</p>