I have just installed the library googletrans
but when i try to translate a simple sentence from English to Italian, it does not work properly. Here is the code:
from googletrans import Translator
translator = Translator()
translation = translator.translate('The quick brown fox', src='en', dest='it')
print(translation.origin, ' -> ', translation.text)
The output is the following: The quick brown fox -> Il quick brown fox
As you can see the translated part is still in English except the article (The -> Il
). How is this possible? How can i make it work correclty?
Note: by using the google translate website i am able to obtain the right translation: La rapida volpe marrone
Nice question. My best guess is there exists some kind of bug in the Translator.
Meanwhile, I can suggest you using translate.
pip install translate
from translate import Translator
translator = Translator(to_lang='it')
translation = translator.translate('The quick brown fox')
print(translation)
The output will be exactly as you wish:
La rapida volpe marrone