خرید بک لینک

Vote count: 0

I 'm currently working on an application translate.I use google translate API v2 and C # . I create a project, I tued on my api.but the problem is that instead of having the translation I receive only the word data.can you help me, here is my code.

public string Translate (string sourceText, string sourceLanguage, string targetLanguage) { // Initialize this.Error = null; string translation = string.Empty;

        try
        {
            // Download translation
            string apiKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
            /*string url = string.Format("https://www.googleapis.com/language/translate/v2?key="+ apiKey + 
                            "&q=" + sourceText +
                            "&source=" + languageSource +
                            "&target=" + languageTraduit);
            string outputFile = Path.GetTempFileName();
            using (WebClient wc = new WebClient())
            {
            wc.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1)  AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36");
                wc.DownloadFile(url, outputFile);
            }

}

private void btnTranslate_Click(object sender, EventArgs e) { Generale g = new Generale();

        this.traductionTextBox.Text = string.Empty;
        this.traductionTextBox.Update();
        this.traduction = null;

        // Translate the text
        try
        {
            this.Cursor = Cursors.WaitCursor;

            this.traductionTextBox.Text = g.Translate(this.sourceTextBox.Text.Trim(), (string)this.fromComboBox.SelectedItem, (string)this.toComboBox.SelectedItem);
            if (g.Error == null)
            {
                this.traductionTextBox.Update();
            }
            else
            {
                MessageBox.Show(g.Error.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 14 خرداد 1395 ساعت: 7:43

صفحه بندی