Google Translate
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
2 posts
Page 1 of 1

This is a sample app written in .NET on how to use the Google Translate API.
Can be ported to your existing App or even use as a Client Google Translator (Windows version).
Feature:
[*]Support all functions of Google Ajax Language API.
[*]CLS compatible. It can be used by any .NET languages (VB.NET, C++/CLI etc.)
Description:
Provides a simple, unofficial, .NET Framework API for using Google Ajax Language API service.
Includes:
[*]2 Textbox
[*]5 Label
[*]1 Combobox
[*]1 Button
Add the references:
- GoogleTranslateAPI.dll
- Newtonsoft.Json.dll
1. Double Click the on Form:
Code: Select all
2. Form1_Load toward:
Me.ComboBox1.Items.Add("English")
Me.ComboBox1.Items.Add("French")
Me.ComboBox1.Items.Add("Chinese")
Me.ComboBox1.Items.Add("Italian")
Me.ComboBox1.Items.Add("German")
Me.ComboBox1.Items.Add("Hungarian")
Me.ComboBox1.Items.Add("Spanish")
Me.ComboBox1.Items.Add("Russian")
Me.ComboBox1.Items.Add("Japanese")
Me.ComboBox1.Items.Add("Korean")
Me.ComboBox1.Items.Add("Arabic")
Me.ComboBox1.Items.Add("Latin")
Me.ComboBox1.Items.Add("Greek")
Me.ComboBox1.Items.Add("Tagalog")
Code: Select all
3. After Form1_Load:
Dim GoogleTranslator As New Google.API.Translate.TranslateClient("")
Dim sourcestring As String
Dim translatedstring As String
Dim ISO_language As String
Code: Select all
4. Double click the on Button1:
Sub chooseLanguage()
If ComboBox1.SelectedIndex = 0 Then
ISO_language = "en"
End If
If ComboBox1.SelectedIndex = 1 Then
ISO_language = "fr"
End If
If ComboBox1.SelectedIndex = 2 Then
ISO_language = "zh-TW"
End If
If ComboBox1.SelectedIndex = 3 Then
ISO_language = "it"
End If
If ComboBox1.SelectedIndex = 4 Then
ISO_language = "de"
End If
If ComboBox1.SelectedIndex = 5 Then
ISO_language = "de"
End If
If ComboBox1.SelectedIndex = 6 Then
ISO_language = "es"
End If
If ComboBox1.SelectedIndex = 7 Then
ISO_language = "ru"
End If
If ComboBox1.SelectedIndex = 8 Then
ISO_language = "ja"
End If
If ComboBox1.SelectedIndex = 9 Then
ISO_language = "ko"
End If
If ComboBox1.SelectedIndex = 10 Then
ISO_language = "ar"
End If
If ComboBox1.SelectedIndex = 11 Then
ISO_language = "la"
End If
If ComboBox1.SelectedIndex = 12 Then
ISO_language = "el"
End If
If ComboBox1.SelectedIndex = 13 Then
ISO_language = "tl"
End If
End Sub
Code: Select all
5. After Button1_Click:
If Me.TextBox1.Text = "" Then
MsgBox("Required Field!!!")
TextBox1.Focus()
Exit Sub
End If
If Me.ComboBox1.Text = "" Then
MsgBox("Required Field!!!")
ComboBox1.Focus()
Exit Sub
End If
Translate()
Code: Select all
Sub Translate()
Try
chooseLanguage()
sourcestring = Me.TextBox1.Text
translatedstring = GoogleTranslator.TranslateAndDetect(sourcestring, ISO_language, "")
Catch ex As Exception
MessageBox.Show("Error while Connecting to Google..." & ex.ToString, "Google API Sample")
End Try
Me.TextBox2.Text = translatedstring
End Sub
You do not have the required permissions to view the files attached to this post.
Thats cool!, looks awsome too. 

If i Help you +Rep cooll;
Im new to visual basic so I probly wont :P
Im new to visual basic so I probly wont :P
2 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023