简体   繁体   English

googletrans 没有完全从英语翻译成意大利语

[英]googletrans not fully translating from English to Italian

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.我刚刚安装了库googletrans ,但是当我尝试将一个简单的句子从英语翻译成意大利语时,它无法正常工作。 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 ). output 如下: The quick brown fox -> Il quick brown fox如您所见,除了文章( 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注意:通过使用谷歌翻译网站,我可以获得正确的翻译: La rapida volpe marrone

Nice question.好问题。 My best guess is there exists some kind of bug in the Translator .我最好的猜测是Translator中存在某种错误。

Meanwhile, I can suggest you using translate .同时,我可以建议您使用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 output 将如您所愿: La rapida volpe marrone

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM