Python Forum
Module googletrans 2.4.0 Question - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Module googletrans 2.4.0 Question (/thread-19194.html)



Module googletrans 2.4.0 Question - hlhp - Jun-17-2019

How to use googletrans for translation.
According to googletrans 2.4.0
I got error even with the official basic code.

from googletrans import Translator
translator = Translator()
translator.translate('안녕하세요.')
# <Translated src=ko dest=en text=Good evening. pronunciation=Good evening.>
translator.translate('안녕하세요.', dest='ja')
# <Translated src=ko dest=ja text=こんにちは。 pronunciation=Kon'nichiwa.>
translator.translate('veritas lux mea', src='la')
# <Translated src=la dest=en text=The truth is my light pronunciation=The truth is my light>
Error:
[Running] python -u "d:\Loading\test\test.py" Traceback (most recent call last): File "d:\Loading\test\test.py", line 3, in <module> translator.translate('\uc548\ub155\ud558\uc138\uc694.') File "C:\Users\myName\Anaconda3\lib\site-packages\googletrans\client.py", line 172, in translate data = self._translate(text, dest, src) File "C:\Users\myName\Anaconda3\lib\site-packages\googletrans\client.py", line 75, in _translate token = self.token_acquirer.do(text) File "C:\Users\myName\Anaconda3\lib\site-packages\googletrans\gtoken.py", line 180, in do self._update() File "C:\Users\myName\Anaconda3\lib\site-packages\googletrans\gtoken.py", line 59, in _update code = unicode(self.RE_TKK.search(r.text).group(1)).replace('var ', '') AttributeError: 'NoneType' object has no attribute 'group' [Done] exited with code=1 in 0.732 seconds
In addition, if using Array call, will it consider one call or multiple calls? Ref Link
Quote:Advanced Usage (Bulk)
Array can be used to translate a batch of strings in a single method call and a single HTTP session. The exact same method shown above work for arrays as well.