Babelfish translation ...

Stef Mientki stef.mientki at gmail.com
Thu Jul 17 07:00:03 EDT 2008


hello,

I've build a translation tool, to translate all strings in a python 
source file.
As a extra gadget I added translation through Babel Fish,
using beautifulsoup.

Although it works functionally,
it can take lots of time waiting for the translation.

What I basically do is, after selecting a new string to be translated:

    kwds = { 'trtext' : line_to_be_translated, 'lp' :'en_nl'}
    soup = BeautifulSoup (urlopen(url, urlencode ( kwds ) ) )
    translation= soup.find ( 'div', style='padding:0.6em;' ).string
    self.Editor_Babel.SetLabel ( translation )

I'm using Python 2.5 and wxPython.

Probably I should use a separate thread, but that's above my knowledge.
I could also use a timer to check at regualr intervals when the 
translation is ready,
but I've no idea how to implement that with the above code.

thanks,
Stef Mientki



More information about the Python-list mailing list