When I use translate Lib in Python to translate text it returns the same text without translation
from translate import Translator
translator= Translator(to_lang="en")
res = translator.translate("C'est la vie")
print(res)
the returned value is the same
C'est la vie
When I use translate Lib in Python to translate text it returns the same text without translation
from translate import Translator
translator= Translator(to_lang="en")
res = translator.translate("C'est la vie")
print(res)
the returned value is the same
Share Improve this question edited Mar 11 at 10:58 Daraan 4,2427 gold badges22 silver badges47 bronze badges asked Mar 11 at 10:56 AhmedAhmed 114 bronze badges 1C'est la vie
- 1 That might be something to ask the author of that library… – deceze ♦ Commented Mar 11 at 11:08
1 Answer
Reset to default 1You missed a key argument in Translator()
, and that is from_lang =
. Here is your corrected code with the translation.
from translate import Translator
translator = Translator(from_lang="fr", to_lang="en")
res = translator.translate("C'est la vie")
print(res)
That's life
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744799954a4594433.html
评论列表(0条)