Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No translations returned when translating list of strings #25

Open
msoutopico opened this issue Apr 6, 2021 · 0 comments
Open

No translations returned when translating list of strings #25

msoutopico opened this issue Apr 6, 2021 · 0 comments

Comments

@msoutopico
Copy link

msoutopico commented Apr 6, 2021

Describe the bug
No translations returned when the request is sent from a script run as a cron job.

To Reproduce
I have a list of sentences, created dynamically, like:
list_of_strings = ['This is one sentence.', 'This is another sentence.', 'etc.']

which I send to Google with function such:

def get_mt_of_list(list_of_strings, src_lang, dest_lang):
  try:
      translations = (translator.translate(list_of_strings, src=google_tag, dest=dest_lang))
      return [xlat.text for xlat in translations]
  except Exception:
      logging.error(Exception)
      return None

My list has 130 sentences in Croatian and a bit above 6,000 characters. I call the script with src_lang='hr' and dest_lang='en'.

Expected behavior
The list of translations.

Actual behviour
When I do it manually in the python interpreter, I get the list of translations. However, when this function is run in my script (called as a cron job), I get the following in my log, 70 times:

[2021-04-06 13:05:28,303] urllib3.connectionpool@connectionpool:971 DEBUG: Starting new HTTPS connection (1): translate.google.com:443
[2021-04-06 13:05:28,348] urllib3.connectionpool@connectionpool:452 DEBUG: https://translate.google.com:443 "POST /_/TranslateWebserverUi/data/batchexecute?rpcids=MkEWBc&bl=boq_translate-webserver_20201207.13_p0&soc-app=1&soc-platform=1&soc-device=1&rt=c HTTP/1.1" 200 None

I get the above 70 times, and then an exception.

The 200 at the end means the request was a success (on the level of http/s), but I get an exception, not the translations. If the API accept it or not, that I don't know.

Desktop (please complete the following information):

  • OS: Ubuntu 20.04.2 LTS
  • python version: 3.8.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant