I was looking around for an example of how to access Google’s Translation services from Python, and all the examples I found seemed too bloated to me, so I decided to write my own, and managed it in just a few lines of code. Perhaps the Ajax API didn’t exist when others wrote theirs, but it’s certainly much easier now.
So here it is, gtrans.py:
url = 'http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q='+urllib.quote(' '.join(sys.argv[3:]))+'&langpair='+sys.argv+'%7C'+sys.argv
transtext = eval(urllib.urlopen(url).read().replace('null,', '"",'))
print "\n", transtext['responseData']['translatedText'], "\n"
textview is my first application written in Genie, a python-like language which is converted into C and then compiled as a normal C program. The language is cross-platform also, and I have compiled textview on Windows just to prove it!
Although I think there’s more than enough text editors available for Linux, I was unable to find a really lightweight text viewer that could also perform basic editing functions. Previously I used leafpad or gedit for this purpose, but even that is overkill, since most of the time I just view Readme files etc. which don’t need syntax highlighting, vast arrays of menu options or dialogs popping up asking me if I want to save etc.
Be warned that textview does not have any undo or backup features, and probably never will. It’s primarily for use as a viewer, not an editor. To enter edit mode, press escape, to return to view-only mode press escape again. To save any changes, press “w” in view-only mode.
textview_0.1.deb (deb package)
textview-windows.zip (compiled for Windows)
You will also need to download GTK for windows to run this.
textview.gs (source code)