Thursday, 6 March 2014

Google Translate In Terminal

I am currently trying to learn french, and just to make life a tad easier, i wrote a wrapper for google translate.

Because when do you not have a terminal handy?

(Psst. I have up a more updated version here)


  1. Simple and elegant :)

  2. Interesting! As I am starting to learn italian (from french), this could come handy. May I suggest a few enhancements to your script?

    1- Use a library that does the http for you instead of using a raw socket. There are many reasons, but it my case, I had to since at work I have to go through a proxy. urllib2 handles that.
    2- You receive you reply in json. Better parse json properly to get the translated phrase.
    3- Try not to catch all the exceptions (the except:). When I tried it the first time, it hanged (because of the proxy issue), and when I did ctrl-C, the script just continued with a bad state from that except instead of stopping.

    Link to my modified version:

    Bonne chance avec le fran├žais!