'Google translate in python
When using this code from https://stackabuse.com/text-translation-with-google-translate-api-in-python/
from googletrans import Translator
translator = Translator()
result = translator.translate("Mitä sinä teet")
print(result.src)
print(result.dest)
print(result.origin)
print(result.text)
I get 'AttributeError: 'NoneType' object has no attribute 'group'', and i was wondering what is wrong, the error seems to be on the 'result = tra...' line,
Thank you for any help
Solution 1:[1]
I think the problem is with the installation of the library because the code worked fine for me. I would suggest you to uninstall and then reinstall the googletrans library.
Solution 2:[2]
with open(os.path.join(files_from_folder, filename), encoding='utf-8') as html:
soup = BeautifulSoup('<pre>' + html.read() + '</pre>', 'html.parser')
for title in soup.findAll('title'):
recursively_translate(title)
See this 2 complete code that can easy translate files with python:
OR
https://neculaifantanaru.com/en/example-python-google-translate-any-text-html-file-version-2.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Soorya Prakash |
| Solution 2 | Just Me |

