Im trying to use google translate api and it dosent work good yet i cant figure out why
<p>This is my code im using. So i have one dll i added as reference: Google.Apis.Translate.V2 
I also bought google translate api key.</p>

<p>This is my code im using now and i have 5 errors since i dont know what dll i need more:
This objects are not exist missing namespace: DataContractJsonSerializer , TranslationRootObject , TranslationRootObject</p>

<p>What dll reference do i need for this namespaces ?</p>

<p>This is my code: ( removed my key just to show my code )</p>

<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Web;

namespace Google_Translate
{
    public partial class Form1 : Form
    {
        static string apiKey = "";

        static string texttotranslate = "hello world";
        string text;
        static String apiUrl = "https://www.googleapis.com/language/translate/v2?key={0}&amp;source={1}&amp;target={2}&amp;q={3}";
            static String url = String.Format(apiUrl, apiKey, "en", "ge", texttotranslate);
            Stream outputStream = null;

        byte[] bytes = Encoding.ASCII.GetBytes(url);

        // create the http web request
        HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);



        public Form1()
        {
            InitializeComponent();

            webRequest.KeepAlive = true;
            webRequest.Method = "POST";
            // Overrride the GET method as documented on Google's docu.
            webRequest.Headers.Add("X-HTTP-Method-Override: GET");
            webRequest.ContentType = "application/x-www-form-urlencoded";
            // send POST
            try
            {
                webRequest.ContentLength = bytes.Length;
                outputStream = webRequest.GetRequestStream();
                outputStream.Write(bytes, 0, bytes.Length);
                outputStream.Close();
            }
            catch (HttpListenerException e)
            {
                /*...*/
            }

            translate();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private string translate()
        {
             try
        {
            // get the response
            HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
            if (webResponse.StatusCode == HttpStatusCode.OK &amp;&amp; webRequest != null)
            {
                // read response stream 
                using (StreamReader sr = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8))
                {
                    string lista = sr.ReadToEnd();

                    DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(TranslationRootObject));
                    MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(lista));
                    TranslationRootObject tRootObject = (TranslationRootObject)serializer.ReadObject(stream);
                    string previousTranslation = string.Empty;

                    //deserialize
                    for (int i = 0; i &lt; tRootObject.Data.Detections.Count; i++)
                    {
                        string translatedText = tRootObject.Data.Detections[i].TranslatedText.ToString();
                        if (i == 0)
                        {
                            text = translatedText;
                        }
                        else
                        {
                            if (!text.Contains(translatedText))
                            {
                                text = text + " " + translatedText;
                            }
                        }
                    }
                    return text;
                }
            }
        }
        catch (HttpListenerException e)
        {
            /*...*/
        }

        return text;



        }
    }
}
</code></pre>

<p>Can someone fix my code or tell me whats wrong please ?</p>

<p>What i need is to translate 29-33kb text file size and i wonder if its possible to translate it as fast as it does online when using the google translate site.</p>

<p>I also found this link <a href="http://stackoverflow.com/questions/9432422/google-translate-v2-cannot-hanlde-large-text-translations-from-c-sharp">Google Translate V2 cannot hanlde large text translations from C#</a> wich someone say the translation cant translate big files so i wonder if 29-33kb files are counting as big ? If so maybe someone can take a look at the link and fix my code according to the answer in the link i tried a lot now and didnt understand it realy. But first i need to find why my original code here dosent work.</p>

<p>Thank you.</p>
