from googletrans import Translator, LANGCODES
Translator = Translator()
with open("bad_blood.txt",mode="r", encoding='utf-8') as textFile:
text = textFile.read()
translation = Translator.translate(text, src="en", dest="fa")
print(translation)
These are the errors of my code and it does not run, I don’t know why?
File “C:UsersuserAppDataRoamingPythonPython312site-packagesgoogletransclient.py”, line 182, in translate
data = self._translate(text, dest, src, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:UsersuserAppDataRoamingPythonPython312site-packagesgoogletransclient.py”, line 78, in _translate
token = self.token_acquirer.do(text)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:UsersuserAppDataRoamingPythonPython312site-packagesgoogletransgtoken.py”, line 194, in do
self._update()
File “C:UsersuserAppDataRoamingPythonPython312site-packagesgoogletransgtoken.py”, line 62, in _update
code = self.RE_TKK.search(r.text).group(1).replace(‘var ‘, ”)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: ‘NoneType’ object has no attribute ‘group’
Mohammad reza is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.