Google Translate API v2 - Use in my project

I have the sample bulid working with api key and client id set up. But How can I use it my my own project? its vb and the samples are all in c#.

Google's getting started guides are only for the samples.

If anyone is using this, Which are the steps I need to take?

Who is Participating?
Ramkisan JagtapLead DeveloperCommented:
Is your project is web application or is it a Desktop application. If its webapplication you can use javascript for Google map.

DabosaAuthor Commented:
Its a Windows forms application, translate api
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

DabosaAuthor Commented:
Im more interested how I can integrate the api in a project.

I dont undertand how to do it from this:

Ramkisan JagtapLead DeveloperCommented:
I am not sure if that is possible, You need to use browser control in your winforms application for that.

DabosaAuthor Commented:
It should be, When I've created the API key it asks me if im going to use it in a desktop app or for web service.. These are the sample files:
Ramkisan JagtapConnect With a Mentor Lead DeveloperCommented:
Please add the Google.Apis.Translate.v2.dll  as reference to your project and below is the VB code for google translate Api.

Imports System.Collections.Generic
Imports System.ComponentModel
Imports Google.Apis.Samples.Helper
Imports Google.Apis.Translate.v2
Imports Google.Apis.Translate.v2.Data
Imports TranslationsResource = Google.Apis.Translate.v2.Data.TranslationsResource
Namespace Translate.TranslateText
      Friend Class Program
            <Description("input")> _
            Public Class TranslateInput
                  <Description("text to translate")> _
                  Public SourceText As String = "Who ate my candy?"
                  <Description("target language")> _
                  Public TargetLanguage As String = "fr"
            End Class
            <STAThread> _
            Private Shared Sub Main(args As String())
                  ' Initialize this sample.      
                  CommandLine.DisplayGoogleSampleHeader("Translate Sample")
                  ' Ask for the user input.              TranslateInput input = CommandLine.CreateClassFromUserinput<TranslateInput>(); // Create the service.              
                  Dim service = New TranslateService() With { _
                        Key .Key = ClientCredentials.ApiKey _
                  CommandLine.WriteAction("Translating to '" + input.TargetLanguage & "' ...")
                  Dim srcText As String() = New () {"Hello world!", input.SourceText}
                  Dim response As TranslationsListResponse = service.Translations.List(srcText, input.TargetLanguage).Fetch()
                  Dim translations = New List(Of String)()
                  For Each translation As TranslationsResource In response.Translations
                        CommandLine.WriteResult("translation", translation.TranslatedText)
                  ' Translate the text (back) to english.        
                  CommandLine.WriteAction("Translating to english ...")
                  response = service.Translations.List(translations, "en").Fetch()
                  For Each translation As TranslationsResource In response.Translations
                        CommandLine.WriteResult("translation", translation.TranslatedText)
                  ' ...and we are done.          
            End Sub
      End Class
End Namespace
DabosaAuthor Commented:
Got it to work, importing all of the resources and using the c# vb converters.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.