Based on findings from 2012 on the net, I have tried out this code:
Imports System.Collections.Generic
Imports System.ComponentModel
Imports Google.Apis.Translate.v2
Imports Google.Apis.Translate.v2.Data
Imports TranslationsResource = Google.Apis.Translate.v2.Data.TranslationsResource
Public Class Form1
Private Sub Translate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Translate.Click
Dim test As New TranslateService()
test.Key = "My 39 characters API Key"
Dim response As TranslationsListResponse = test.Translations.List(Txtfrom.Text, "da").Fetch()
Dim translations As New List(Of String)()
For Each t As TranslationsResource In response.Translations
'Console.WriteLine(t.TranslatedText)
txtto.Text = t.TranslatedText
Next
End Sub
End Class
My projects Service References includes:
Google.Apis
Type .NET
Version 1.1.4497.35846
Google.Apis.Translate.v2
Type .NET
Version 1.1.4497.35829
It does not work - at debug 'Dim test As New TranslateService()' throws:
A first chance exception of type 'System.TypeInitializationException' occurred in Google.Apis.dll
The result language in the example is French but as my source text is rather technical I would like to define both source (English) and result language (Swedish,Polish and Russian).
Further I don't fully understand the For Each loop getting the resulting translation.