nayaksomesh / google-api-for-dotnet

Automatically exported from code.google.com/p/google-api-for-dotnet
0 stars 0 forks source link

[Need Help] Google Translate Api on VB.NET 2005 express edition #54

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. add reference Google Translate API for .NET 0.4 alpha dll into my VB.NET
2005 project (named; VoiceBrowser)
2. created combobox for user-selected translated language, textbox for 
input text / translated text, and a button for translate.
3. add all code needed as I found on this web google-api-for-dotnet

What is the expected output? What do you see instead?
im expected translated indonesian language to english language by pressing
the button, but i see an error instead, its says. 
"Google.Api.Enumeration.op_implicit(Google.Api.Enumeration)
VoiceBrowser.frmTTS.Button1_cilck" >> I set the error message to show up
what currently using method that cause an error but I dont know where the
method is it (enumeration.op_implicit)

What version of the product are you using? On what operating system?
VB.net 2005 Express edition, no windows XP SP2

Please provide any additional information below.
I just need to implement a basic code for translating language in my
program by using google api dll reference, but its really annoying me cause
i cant found any sample code for this, the one I got is from this web
(thanks to iron9) but it still cant function properly..

maybe some1 who have try this code before can help me..
my code=

Private Function GoogleTranslate(ByVal Input As String, ByVal FromLanguage
As String, ByVal ToLangugage As String) As String

Dim GoogleTransClient As New Google.API.Translate.TranslateClient("")
Dim TranslatedString As String
Dim FromLanguageGoogle As Google.API.Translate.Language
Dim ToLanguageGoogle As Google.API.Translate.Language

Try
If FromLanguage.Contains("English") Then
   FromLanguageGoogle = Google.API.Translate.Language.English
Else
   FromLanguageGoogle = Google.API.Translate.Language.Indonesian
End If

If ToLangugage.Contains("English") Then
   ToLanguageGoogle = Google.API.Translate.Language.English
Else
   ToLanguageGoogle = Google.API.Translate.Language.Indonesian
End If

TranslatedString = GoogleTransClient.Translate(Input, FromLanguageGoogle,
ToLanguageGoogle, Google.API.Translate.TranslateFormat.Text)
Return TranslatedString

Catch ex As Exception
MessageBox.Show(String.Format("{0}{1}{2}.{3}", ex.Message, vbCrLf,
GetCurrentMethod.ReflectedType, GetCurrentMethod.Name), "",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Return Nothing
end function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Try
RTBTranslated.Text = GoogleTranslate(RTBBrowser.Text,
cboGoogleFromLanguage.Text, cboGoogleToLanguage.Text)

Catch ex As Exception
MessageBox.Show(String.Format("{0}{1}{2}.{3}", ex.Message, vbCrLf,
GetCurrentMethod.ReflectedType, GetCurrentMethod.Name), "",
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub

Original issue reported on code.google.com by handokol...@gmail.com on 23 May 2010 at 3:40

GoogleCodeExporter commented 9 years ago
Enumeration.op_implicit is here:
http://code.google.com/p/google-api-for-dotnet/source/browse/trunk/src/Core/Enum
eration.cs#116

What's the error message?

It may be the same bug described in Issue48.

Original comment by iron9li...@gmail.com on 25 May 2010 at 6:41

GoogleCodeExporter commented 9 years ago
thanks for reply my message,

I have look for issue48 and the enumeration,

for issue48,  Chupakabr said that >
GoogleTranslateAPI_0.4_alpha.zip does not work because missing cast operator in 
Language.cs add 
 public static implicit operator string(Language value)
        {
            return value.Value;
       }
at 599 line in Language.cs to fix this

where can I found the language.cs?

for enumeration.cs, what is that means?
I could see that the code is a namespace,
do I need to add the namespace= google.api in my project to fix the error 
message?
if yes, how could I add it? can I just copy and paste the code on the class 
file (.vb)?

sorry if I have ask to many Questions..

Original comment by handokol...@gmail.com on 25 May 2010 at 8:53

GoogleCodeExporter commented 9 years ago
The easiest way is use string but not Enumeration as the parameter.(e.g. use 
"en" but
not Language.English)

Original comment by iron9li...@gmail.com on 25 May 2010 at 2:10

GoogleCodeExporter commented 9 years ago
Hi iron9light,

I have try to use string instead using combobox for language translate,
and wow! the program is finally start to translate! really thanks for your help!

Original comment by handokol...@gmail.com on 6 Jun 2010 at 6:47