You used to be able to use nltk.misc.babelfish
to translate things, but the Yahoo Babelfish API went down. Is there an easy way I can, say, do this?
>>> import translate
>>> translate('carpe diem', 'latin', 'english')
'seize the day'
Automated translation may be used to automate the machine translation of text as a stage in the localization workflow. However, automated translation and machine translation are not interchangeable terms as they serve entirely different functions.
Hybrid Machine Translation is a method of machine translation that is characterized by the use of multiple machine translation approaches within a single machine translation system.
You can also translate text documents via Google Translate API. All you have to do is to read the text file in Python using the open method, read the text and pass it to the translate() method.
Goslate is a good library for this that uses Google Translate: http://pythonhosted.org/goslate/
Here's the example from the docs:
>>> import goslate
>>> gs = goslate.Goslate()
>>> print(gs.translate('hello world', 'de'))
hallo welt
In order to go from "carpe diem" to "seize the day":
>>> print(gs.translate('carpe diem', 'en', 'la'))
seize the day
So it's essentially the same as the Babelfish API used to be, but the order of the target and source languages is switched. And one more thing -- if you need to figure out the short code, gs.get_languages()
will give you a dictionary of all the short codes for each supported language: {...'la':'Latin'...}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With