translate-shell icon indicating copy to clipboard operation
translate-shell copied to clipboard

Blank lines output when translating file

Open jrwrigh opened this issue 5 years ago • 5 comments

I just started using trans a few minutes ago. Initially, it worked fine. But for some reason, it just stopped all of a sudden. Here's the output you asked for in a previous similar problem:

➜ trans -D fr: dejeuner
  31 bytes > HTTP/1.1 429 Too Many Requests
  36 bytes > Date: Mon, 25 May 2020 15:45:03 GMT
  17 bytes > Pragma: no-cache
  39 bytes > Expires: Fri, 01 Jan 1990 00:00:00 GMT
  51 bytes > Cache-Control: no-store, no-cache, must-revalidate
  24 bytes > Content-Type: text/html
  30 bytes > Server: HTTP server (unknown)
  21 bytes > Content-Length: 2189
  20 bytes > X-XSS-Protection: 0
  18 bytes > Connection: close
   1 bytes > 
  63 bytes > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
   6 bytes > <html>
 385 bytes > <head><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta name="viewport" content="initial-scale=1"><title>http://translate.googleapis.com/translate_a/single?client=gtx&amp;ie=UTF-8&amp;oe=UTF-8&amp;dt=bd&amp;dt=ex&amp;dt=ld&amp;dt=md&amp;dt=rw&amp;dt=rm&amp;dt=ss&amp;dt=t&amp;dt=at&amp;dt=gt&amp;dt=qca&amp;sl=fr&amp;tl=en&amp;hl=en&amp;q=dejeuner</title></head>
 177 bytes > <body style="font-family: arial, sans-serif; background-color: #fff; color: #000; padding:20px; font-size:18px;" onload="e=document.getElementById('captcha');if(e){e.focus();}">
  30 bytes > <div style="max-width:400px;">
  68 bytes > <hr noshade size="1" style="color:#ccc; background-color:#ccc;"><br>
  29 bytes > <div style="font-size:13px;">
 222 bytes > Our systems have detected unusual traffic from your computer network.  Please try your request again later.  <a href="#" onclick="document.getElementById('infoDiv0').style.display='block';">Why did this happen?</a><br><br>
 116 bytes > <div id="infoDiv0" style="display:none; background-color:#eee; padding:10px; margin:0 0 15px 0; line-height:1.4em;">
 730 bytes > This page appears when Google automatically detects requests coming from your computer network which appear to be in violation of the <a href="//www.google.com/policies/terms/">Terms of Service</a>. The block will expire shortly after those requests stop.<br><br>This traffic may have been sent by malicious software, a browser plug-in, or a script that sends automated requests.  If you share your network connection, ask your administrator for help &mdash; a different computer using the same IP address may be responsible.  <a href="//support.google.com/websearch/answer/86640">Learn more</a><br><br>Sometimes you may see this page if you are using advanced terms that robots are known to use, or sending requests very quickly.
  10 bytes > </div><br>
   0 bytes > 
 310 bytes > IP address: 67.190.84.172<br>Time: 2020-05-25T15:45:03Z<br>URL: http://translate.googleapis.com/translate_a/single?client=gtx&amp;ie=UTF-8&amp;oe=UTF-8&amp;dt=bd&amp;dt=ex&amp;dt=ld&amp;dt=md&amp;dt=rw&amp;dt=rm&amp;dt=ss&amp;dt=t&amp;dt=at&amp;dt=gt&amp;dt=qca&amp;sl=fr&amp;tl=en&amp;hl=en&amp;q=dejeuner<br>
   6 bytes > </div>
   6 bytes > </div>
   7 bytes > </body>
   7 bytes > </html>
content = '''
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta name="viewport" content="initial-scale=1"><title>http://translate.googleapis.com/translate_a/single?client=gtx&amp;ie=UTF-8&amp;oe=UTF-8&amp;dt=bd&amp;dt=ex&amp;dt=ld&amp;dt=md&amp;dt=rw&amp;dt=rm&amp;dt=ss&amp;dt=t&amp;dt=at&amp;dt=gt&amp;dt=qca&amp;sl=fr&amp;tl=en&amp;hl=en&amp;q=dejeuner</title></head>
<body style="font-family: arial, sans-serif; background-color: #fff; color: #000; padding:20px; font-size:18px;" onload="e=document.getElementById('captcha');if(e){e.focus();}">
<div style="max-width:400px;">
<hr noshade size="1" style="color:#ccc; background-color:#ccc;"><br>
<div style="font-size:13px;">
Our systems have detected unusual traffic from your computer network.  Please try your request again later.  <a href="#" onclick="document.getElementById('infoDiv0').style.display='block';">Why did this happen?</a><br><br>
<div id="infoDiv0" style="display:none; background-color:#eee; padding:10px; margin:0 0 15px 0; line-height:1.4em;">
This page appears when Google automatically detects requests coming from your computer network which appear to be in violation of the <a href="//www.google.com/policies/terms/">Terms of Service</a>. The block will expire shortly after those requests stop.<br><br>This traffic may have been sent by malicious software, a browser plug-in, or a script that sends automated requests.  If you share your network connection, ask your administrator for help &mdash; a different computer using the same IP address may be responsible.  <a href="//support.google.com/websearch/answer/86640">Learn more</a><br><br>Sometimes you may see this page if you are using advanced terms that robots are known to use, or sending requests very quickly.
</div><br>

IP address: 67.190.84.172<br>Time: 2020-05-25T15:45:03Z<br>URL: http://translate.googleapis.com/translate_a/single?client=gtx&amp;ie=UTF-8&amp;oe=UTF-8&amp;dt=bd&amp;dt=ex&amp;dt=ld&amp;dt=md&amp;dt=rw&amp;dt=rm&amp;dt=ss&amp;dt=t&amp;dt=at&amp;dt=gt&amp;dt=qca&amp;sl=fr&amp;tl=en&amp;hl=en&amp;q=dejeuner<br>
</div>
</div>
</body>
</html>
'''
tokens = ["<!DOCTYPE", "html", "PUBLIC", "\"-//W3C//DTD HTML 4.01 Transitional//EN\"", ">", "<html>", "<head><meta", "http-equiv=", "\"content-type\"", "content=", "\"text/html; charset=utf-8\"", "><meta", "name=", "\"viewport\"", "content=", "\"initial-scale=1\"", "><title>http:", "<body", "style=", "\"font-family: arial, sans-serif; background-color: #fff; color: #000; padding:20px; font-size:18px;\"", "onload=", "\"e=document.getElementById('captcha');if(e){e.focus();}\"", ">", "<div", "style=", "\"max-width:400px;\"", ">", "<hr", "noshade", "size=", "\"1\"", "style=", "\"color:#ccc; background-color:#ccc;\"", "><br>", "<div", "style=", "\"font-size:13px;\"", ">", "Our", "systems", "have", "detected", "unusual", "traffic", "from", "your", "computer", "network", ".", "Please", "try", "your", "request", "again", "later", ".", "<a", "href=", "\"#\"", "onclick=", "\"document.getElementById('infoDiv0').style.display='block';\"", ">Why", "did", "this", "happen?</a><br><br>", "<div", "id=", "\"infoDiv0\"", "style=", "\"display:none; background-color:#eee; padding:10px; margin:0 0 15px 0; line-height:1.4em;\"", ">", "This", "page", "appears", "when", "Google", "automatically", "detects", "requests", "coming", "from", "your", "computer", "network", "which", "appear", "to", "be", "in", "violation", "of", "the", "<a", "href=", "\"//www.google.com/policies/terms/\"", ">Terms", "of", "Service</a>", ".", "The", "block", "will", "expire", "shortly", "after", "those", "requests", "stop", ".", "<br><br>This", "traffic", "may", "have", "been", "sent", "by", "malicious", "software", ",", "a", "browser", "plug-in", ",", "or", "a", "script", "that", "sends", "automated", "requests", ".", "If", "you", "share", "your", "network", "connection", ",", "ask", "your", "administrator", "for", "help", "&mdash", "</div><br>", "IP", "address:", "67.190", ".84", ".172", "<br>Time:", "2020", "-0", "5", "-25", "T", "15", ":", "45", ":", "0", "3", "Z<br>URL:", "http:", "</div>", "</div>", "</body>", "</html>"]
ast = {
"0"	"software"
"1"	"plug-in"
"2"	"connection"
"3"	"</html>"
}
-- display original text & phonetics


-- display major translation & phonetics

Running without the -D flag yields nothing similarly:

➜ trans fr: dejeuner 

jrwrigh avatar May 25 '20 15:05 jrwrigh

Reading through the actual message, I see:

Our systems have detected unusual traffic from your computer network.  Please try your request again later.  <a href="#" onclick="document.getElementById('infoDiv0').style.display='block';">Why did this happen?</a><br><br>

and

This page appears when Google automatically detects requests coming from your computer network which appear to be in violation of the <a href="//www.google.com/policies/terms/">Terms of Service</a>. The block will expire shortly after those requests stop.<br><br>This traffic may have been sent by malicious software, a browser plug-in, or a script that sends automated requests.  If you share your network connection, ask your administrator for help &mdash; a different computer using the same IP address may be responsible.  <a href="//support.google.com/websearch/answer/86640">Learn more</a><br><br>Sometimes you may see this page if you are using advanced terms that robots are known to use, or sending requests very quickly.

I'm trying to translate an entire document, so I'm not sure if there's a better way of doing this. The file is 1380 lines long (though with a lot of blank lines in it). The command I'm using is trans :ru file://VSTGRusOCR.txt -o VSTGRusOCR_trans.txt.

jrwrigh avatar May 25 '20 15:05 jrwrigh

Same for me, although I'm translating 10 requests for 10 words and 10-15 seconds inbetween requests. Maybe it's a regional issue with Google translate API?

doneforaiur avatar Jul 18 '20 06:07 doneforaiur

Same for me, I failed to get any kind of output, for any test input.

binyominzeev avatar Aug 30 '20 15:08 binyominzeev

Is it a google issue? I kept running into this problem when my input file is more than 200 lines etc.

ipstone avatar Oct 13 '20 14:10 ipstone

It happens when you try to translate same word again and again (4-6 times for me). One way to fix this is by using vpn.

superRaptor911 avatar Nov 21 '20 07:11 superRaptor911