14

Is there a Python module for the translation of texts from one human language to another? I'm planning to work with texts that are to be pre and post processed with Python scripts. What other Python-integrated approaches can be used?

Kara
  • 6,115
  • 16
  • 50
  • 57
Alex
  • 43,191
  • 44
  • 96
  • 127

5 Answers5

13

If you're looking to actually translate a string of text between two languages, say from English "Hello" to Spanish "Hola", you might want to look into the Google Language API.

Another alternative due to recent deprecation of the free version of Google's API is the Bing Translator API.

Lastly, Google Cloud Platform offers the Translate API as a service, costing about $1 USD per 50,000 characters translated.

JJ Geewax
  • 10,342
  • 1
  • 37
  • 49
  • 2
    From Google Code "Google Translate API v1 was officially deprecated on May 26, 2011; it will be shut off completely on December 1, 2011. For text translations, you can use the Google Translate API v2, which is now available as a paid service." Any alternatives? – Josep Valls Jun 19 '12 at 13:34
  • @JJ Geewax Google Translate API is right now paid services. Is there any server for free in language offline translation for python developer – DASADIYA CHAITANYA Aug 25 '16 at 14:33
  • I don't know of any off-hand, but with Google Translate's current (Aug 2016) pricing, $1 USD buys you 50,000 characters translated, which seems pretty reasonable. – JJ Geewax Aug 26 '16 at 17:08
  • Is there any offline python translator available? I'm ok with downloading the language packages. – Yashraj Nigam Aug 09 '21 at 05:45
5

The Python Natural Language Toolkit will almost certainly be useful to you:

"Open source Python modules, linguistic data and documentation for research and development in natural language processing"

I don't believe it will do translation directly, but it's great for machine understanding of natural language text.

RichieHindle
  • 272,464
  • 47
  • 358
  • 399
3

Python supports gettext. Check out the docs here.

Pinochle
  • 5,515
  • 2
  • 26
  • 20
3

If you want to translate arbitrary (natural) text, check out Goslate, a free python API to Google Translation Services. According to this website, code is as easy as this:

import goslate
gs = goslate.Goslate()
print(gs.translate('hello world', 'de'))

You can pip install using

pip install goslate
Annerose N
  • 477
  • 6
  • 14
0

What to use depends on what you want to translate.

  1. Texts that are a part of your application, like UI etc. Then use gettext directly, or zope.i18n, which wraps gettext so it's easier to use.
  2. Arbitrary texts: The Google Translation API is the thing for you.
  3. "Content", ie things that the user of the application will modify and translate: Well... nothing, really. You have to implement that yourself.

On your description, it sounds like you are after #2.

Lennart Regebro
  • 167,292
  • 41
  • 224
  • 251