Program: Is this possible?

Soldato
Joined
18 Aug 2006
Posts
10,048
Location
ChCh, NZ
Let it first be made clear that I'm solely a hobbyist programmer with novice-intermediate skills. So please keep any comments simple. Talk to me as if I'm stupid (granted, not a big stretch).

I'm trying to learn some Swedish. Instead of spending money on lessons or books, I was thinking of writing a program that could translate individual words or simple sentences for me. That would be the basis of the program. I can expand on it later on.

So basically, I want to type in a single word, e.g. 'Spoon', click the 'Translate' button and have the translated word appear in a text box. That's where the snag is. Is it possible to code something where it takes the word to Google, translate it, and send it back to the program? Google Translate is a damn good resource for translating and it would be awesome if I could work it into the program. I'm sure it is, I just don't quite know how to go by building that into the program.

Furthermore, I want to take the translated word, save it into a SQL database and have it appear on a list. So basically, once the word is translated, it won't ever be lost to the program. That way I can slowly build a library of words and recall them instantly. From there I can do all sorts of neat tricks, but that I don't need help with. Just the translating bit.

I'll be writing this in C♯ as it's the only language I can comfortably work with.
 
Google have an API which will do this for you. Take a look here - http://code.google.com/apis/language/translate/v2/using_rest.html#WorkingResults

You will have to sign up for an API key (which I think is free for personal use). Once you've got that you should be able to call the url from C# and get the translated text from the page you get back.

In order to call the url, you might want to look into the HttpWebRequest and HttpWebResponse classes in C#. There are quite a few examples on the web which show you how to use them.

Hope this helps :)
 
One thing that might be an issue for you is that not all words translate 1 to 1 so surely it would be better to call the google translate API for everything rather than looking at local storage first as the context could make the difference. Sounds cool though :)
 
Interesting project. I'm just going to echo the comments about the google translate API. Its pretty much the only way of doing what you want for free.

As for the library, I'd just do a simple query entry, and save the result as either a word or a sentence. Don't try and extract words from a translated sentence.
 
Back
Top Bottom