Im trying to develop something that is able to accept a txt file and translate what ever is in it to the languages which I have given it. I made a small test with this as I dont use python but I get this error when trying to translate.
AttributeError: 'NoneType' object has no attribute 'group'"
The Code:
import re
import googletrans
from googletrans import Translator
file_translator = Translator()
tFile = open('demo.txt', 'r')
if tFile.mode == 'r':
content = tFile.read()
print(content)
result = file_translator.translate(content, dest='fr')
with open('output.txt', 'w') as outFile:
outFile.write(result.text)
It's a problem with version 3.0.0. You need to install latest version:
pip install googletrans==4.0.0-rc1