Search code examples
pythonutf-8translate

there is problem for python googletrans utf-8 side


from googletrans import Translator

translator = Translator()
translation = translator.translate("Hello friends", src="en", dest='tr')

print(translation.text)

output:

Merhaba arkadaÅŸlar

But it was supposed to be "Merhaba arkadaşlar" not "Merhaba arkadaÅŸlar". I'm trying to apply utf-8 to the output but it doesn't work.


Solution

  • I just checked this directly using the API thru cmd it does translate it correctly. There was a bug posted on this before (linked from this post), which I believe to be what you might be seeing. Perhaps you may need to update the installed module or try the option to use str.replace.

    This is the result from the curl request thru cmd:

    {
      "data": {
        "translations": [
          {
            "translatedText": "Merhaba arkadaşlar"
          }
        ]
      }
    }