thomashempel / AlfredGoogleTranslateWorkflow

A workflow for Alfred that implements translation from any language to any other language that is supported by google
MIT License
401 stars 41 forks source link

Broken on OS X El Capitan #23

Closed alexreg closed 8 years ago

alexreg commented 8 years ago

Since upgrading, it has immediately stopped working. I now get "No results found" for whatever source/destination language & text.

superandrew commented 8 years ago

I've got this problem, too.

thomashempel commented 8 years ago

I have this occasionally since I updated to El Capitan. For some reason, Google says, that there are to many requests from that network. To me, that doesn't make much sense, since the network did not change for me.

Maybe El Capitan does something differently but not sure what. I'm investigating.

thomashempel commented 8 years ago

Can you please try the following.

Open the workflow folder and open the file "GoogleTranslateWorkflow.php". Go to line 115 and replace it with the following

$url = 'http://translate.google.com/translate_a/t?client=foobar&text='.urlencode($phrase).'&hl=en-EN&sl='.$sourceLanguage.'&tl='.$targetLanguage.'&multires=1&ssel=0&tsel=0&sc=1&ie=UTF-8&oe=UTF-8';
thomashempel commented 8 years ago

Oh, and one other thing. In the same file, line 127 is commented. Please remove the comment by removing the two slashes at the beginning of the line.

Start a request and post the content of the file "/tmp/alfred.out" here.

You probably want to re-add the slashes back afterwards.

Thanks and best wishes, Thomas

alexreg commented 8 years ago

I made that change $url = ... on line 114, not 115 (I think you meant this), and it seems to be working well again now.

Here's alfred.out in any case: https://gist.github.com/anonymous/8d278b50e09ca41f7a01

Cheers.

andrielfn commented 8 years ago

I've changed the line 114 and worked for me as well. :+1: :ok_hand:

andrielfn commented 8 years ago

Actually it just works a few times after change the URL. Seems that Google is blocking the request.

The output:

Our systems have detected unusual traffic from your computer network. Please try your request again later. Why did this happen?

thomashempel commented 8 years ago

@alexreg Well, as @andrielfn already stated, that should not work for long. Can you please provide the alfred.out from a request that didn't work?

@andrielfn Can you also provide an alfred.out please?

alexreg commented 8 years ago

Ah yes, it’s broken again now. See this log: https://gist.github.com/19e1fdd2f97499c35f56

On 8 Oct 2015, at 17:24, Thomas Hempel notifications@github.com wrote:

@alexreg https://github.com/alexreg Well, as @andrielfn https://github.com/andrielfn already stated, that should not work for long. Can you please provide the alfred.out from a request that didn't work?

@andrielfn https://github.com/andrielfn Can you also provide an alfred.out please?

— Reply to this email directly or view it on GitHub https://github.com/thomashempel/AlfredGoogleTranslateWorkflow/issues/23#issuecomment-146602130.

thomashempel commented 8 years ago

@alexreg @andrielfn Do you guys still have the problems? I don't have the problems anymore, without any changes to the workflow.

I hope this was a fluke in the Google spam detection, since I don't see what I could do about this problem.

alexreg commented 8 years ago

Working now for me. So yeah, could well have just been a problem with the Google servers and their dodgy DOS detection.

On 9 Oct 2015, at 13:46, Thomas Hempel notifications@github.com wrote:

@alexreg https://github.com/alexreg @andrielfn https://github.com/andrielfn Do you guys still have the problems? I don't have the problems anymore, without any changes to the workflow.

I hope this was a fluke in the Google spam detection, since I don't see what I could do about this problem.

— Reply to this email directly or view it on GitHub https://github.com/thomashempel/AlfredGoogleTranslateWorkflow/issues/23#issuecomment-146858134.

alexreg commented 8 years ago

Not working again now. Same error. :(

On 9 Oct 2015, at 13:46, Thomas Hempel notifications@github.com wrote:

@alexreg https://github.com/alexreg @andrielfn https://github.com/andrielfn Do you guys still have the problems? I don't have the problems anymore, without any changes to the workflow.

I hope this was a fluke in the Google spam detection, since I don't see what I could do about this problem.

— Reply to this email directly or view it on GitHub https://github.com/thomashempel/AlfredGoogleTranslateWorkflow/issues/23#issuecomment-146858134.

thomashempel commented 8 years ago

I just release a new version 3.0.2 that tries to reduce the number of requests, sent to Google. This is not immediate fix but might help in the long run.

thomashempel commented 8 years ago

@alexreg Do you still have the problem? It seems to be fixed for me.

superandrew commented 8 years ago

I seem to still have the problem with version 3.0.2, am I the only one?

`:~ ******$ tail -f /tmp/alfred.out Our systems have detected unusual traffic from your computer network. Please try your request again later. Why did this happen?


IP address: 188.10.34.184
Time: 2015-10-14T08:36:06Z
URL: http://www.google.com/

`

thomashempel commented 8 years ago

Yeah, me too. Problem is back. It worked the last two days, though.

alexreg commented 8 years ago

I still have the problem I'm afraid.

(Did you update the Packal version? I think I'm on the latest.)

Sent from my iPhone

On 14 Oct 2015, at 09:37, Thomas Hempel notifications@github.com wrote:

Yeah, me too. It worked the last two days, though.

— Reply to this email directly or view it on GitHub.

thomashempel commented 8 years ago

Yes, I've the packal version as well.

This is some serious bad news, I have no idea what I can do about this at the moment.

andrielfn commented 8 years ago

Seems that Google is not accepting many requests from the same IP in a specific interval. Every morning when I use the workflow, it works, but after some translations the error appears again.

I started to debugging the URL and I found a pattern that seems to be working all the time (at least for me):

curl -s -A "Mozilla" "http://translate.google.com/translate_a/single?client=t&q=dog&hsl=en&tl=pt-BR&multires=1&ssel=0&tsel=0&sc=1&ie=UTF-8&oe=UTF-8&tk"

I replaced the /t endpoint to /single, the text parameter to q and appended a &tk parameter at the end.

It returned [,,"en"].

Based on that, I found another URL on Google that performs better:

curl -s -A "Mozilla" "http://translate.google.com/translate_a/single?client=t&ie=UTF-8&oe=UTF-8&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&q=car&sl=en&tl=pt-BR&hl=en-EN&tk"

It returns something like this:

[["carro","car",,,0],[,,,"kär"]],[["noun",["carro","automóvel","viatura","vagão","carruagem","cabine de elevador","carro de máquina de escrever"],[["carro",["car","carriage","vehicle","automobile","auto","lorry"],[24468],0.50283158,"o"],["automóvel",["car","automobile","motor","vehicle","motor car","machine"],[24468],0.034218118,"o"],["viatura",["car","vehicle","carriage"],,0.0040234118,"a"],["vagão",["wagon","car","waggon","caboose"],[24468],0.0011893183,"o"],["carruagem",["carriage","coach","car","vehicle","barouche","equipage"],,0.00019415087,"a"],["cabine de elevador",["car"],,5.1229e-07,"a"],["carro de máquina de escrever",["car"]...

I know that this return is far different from the what the /t endpoint returns, but perhaps it can help you to find a better solution.

alexreg commented 8 years ago

That's some good investigative work there, @andrielfn. I confirm the results you get. @thomashempel What do you think, do you want to release a new version with the latter URL now?

thomashempel commented 8 years ago

@andrielfn Awesome work. I'll check it over the weekend. Thank you!!!

alexreg commented 8 years ago

Still patchy service for me… on one day (or hour even), off the next.

On 16 Oct 2015, at 19:58, Thomas Hempel notifications@github.com wrote:

@andrielfn https://github.com/andrielfn Awesome work. I'll check it over the weekend. Thank you!!!

— Reply to this email directly or view it on GitHub https://github.com/thomashempel/AlfredGoogleTranslateWorkflow/issues/23#issuecomment-148806902.

thomashempel commented 8 years ago

Yeah, sorry. Because of illness and other circumstances, I didn't had the time to check the possible solution given by @andrielfn yet.

alexreg commented 8 years ago

No problem. Look forward to updates in due course!

Sent from my iPhone

On 2 Nov 2015, at 06:34, Thomas Hempel notifications@github.com wrote:

Yeah, sorry. Because of illness and other circumstances, I didn't had the time to check the possible solution given by @andrielfn yet.

— Reply to this email directly or view it on GitHub.

Meflou commented 8 years ago

I wonder if by now this problem was solved, I still get no result found. Will it work if I downgrade to a previous version?

alexreg commented 8 years ago

Nope, still waiting for @thomashempel to try out the suggested fix and make an update.

Sent from my iPhone

On 27 Nov 2015, at 15:01, Meflou notifications@github.com wrote:

I wonder if by now this problem was solved, I still get no result found. Will it work if I downgrade to a previous version?

— Reply to this email directly or view it on GitHub.

thomashempel commented 8 years ago

Hey, I'm still here. Going through some rough times right now. Will look at this asap.

thomashempel commented 8 years ago

After a first look I can verify, that the URL to the /single endpoint indeed returns some results. But, it only does when the User Agent is set to "Mozilla" via the -A option in Curl. When I leave out the agent, I get the same 403 message.

Unfortunately, this does not work with the /t endpoint. I guess I have to poke a round a little more because the result not always contain any actual translations.

For example

curl -i -A "Mozilla" "http://translate.google.com/translate_a/single?client=t&ie=UTF-8&oe=UTF-8&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&hl=en-EN&tk&q=Haus&sl=auto&tl=en"

returns

[[["Haus","Haus",,,0]],,"en",,,,0.530572,,[["en","de"],,[0.530572,0.43392506]]]%

which is rather useless, since I already know what the german word for "house" is. ;-)

Interestingly enough, when I just paste the URLs that are used in the workflow into my browser, a valid result is returned. So maybe this all boils down to user-agents. I will investigate.

alexreg commented 8 years ago

No problem. Thanks for letting us know you’re still there!

On 27 Nov 2015, at 15:06, Thomas Hempel notifications@github.com wrote:

Hey, I'm still here. Going through some rough times right now. Will look at this asap.

— Reply to this email directly or view it on GitHub https://github.com/thomashempel/AlfredGoogleTranslateWorkflow/issues/23#issuecomment-160156639.

alexreg commented 8 years ago

Interesting. Even Chrome or Safari as user agents doens’t work?

On 27 Nov 2015, at 15:35, Thomas Hempel notifications@github.com wrote:

After a first look I can verify, that the URL to the /single endpoint indeed delivers returns some results. But, it only does when the User Agent is set to "Mozilla" via the -A option in Curl. When I leave out the agent, I get the same 403 message.

Unfortunately, this does not work with the /t endpoint. I guess I have to poke a round a little more because the result not always contain any actual translations.

For example

curl -i -A "Mozilla" "http://translate.google.com/translate_a/single?client=t&ie=UTF-8&oe=UTF-8&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&hl=en-EN&tk&q=Haus&sl=auto&tl=en" returns

[[["Haus","Haus",,,0]],,"en",,,,0.530572,,[["en","de"],,[0.530572,0.43392506]]]% which is rather useless, since I already know what the german word for "house" is. ;-)

Interestingly enough, when I just paste the URLs that are used in the workflow into my browser, a valid result is returned. So maybe this all boils down to user-agents. I will investigate.

— Reply to this email directly or view it on GitHub https://github.com/thomashempel/AlfredGoogleTranslateWorkflow/issues/23#issuecomment-160161475.

thomashempel commented 8 years ago

It seems like Google doesn't like to be requested via cURL. At least I found a few issues related to this.

Unfortunately, there seems to be no working solution for this. :-(

Meflou commented 8 years ago

Thank you for the good spirit guys. I love what you are doing.

alexreg commented 8 years ago

@thomashempel Did you try setting the user-agent with cURL? This usually does the job for me.

thomashempel commented 8 years ago

@alexreg Yes I tried that, but it only works for a few request and doesn't work at all when I try it inside the workflow.

As I wrote above, there are a few articles / stack overflow questions about this. Unfortunately, I couldn't find any solution as of yet.

The whole translate API from Google is a paid service, so I'm seriously thinking to switch to dict.cc. What do you guys think about that?

alexreg commented 8 years ago

I think that’s a good idea, in truth. Let’s switch to dict.cc. :)

On 17 Dec 2015, at 18:03, Thomas Hempel notifications@github.com wrote:

@alexreg https://github.com/alexreg Yes I tried that, but it only works for a few request and doesn't work at all when I try it inside the workflow.

As I wrote above, there are a few articles / stack overflow questions about this. Unfortunately, I couldn't find any solution as of yet.

The whole translate API from Google is a paid service, so I'm seriously thinking to switch to dict.cc. What do you guys think about that?

— Reply to this email directly or view it on GitHub https://github.com/thomashempel/AlfredGoogleTranslateWorkflow/issues/23#issuecomment-165533351.

thomashempel commented 8 years ago

Maybe as a second option, or I just support both. Shouldn't be to hard to implement. I will look into this over the holidays. :-)

alexreg commented 8 years ago

Well if Google’s not working any more, no point supporting it at all. I hear the Bing Translate service has a free option with a fair amount of requests per day. Maybe make Bing and dict.cc the options?

Anyway thanks for your efforts!

On 17 Dec 2015, at 18:06, Thomas Hempel notifications@github.com wrote:

Maybe as a second option, or I just support both. Shouldn't be to hard to implement. I will look into this over the holidays. :-)

— Reply to this email directly or view it on GitHub https://github.com/thomashempel/AlfredGoogleTranslateWorkflow/issues/23#issuecomment-165534115.

thomashempel commented 8 years ago

Good idea! Never hurts to have options. Guess I have to change the name then.

alexreg commented 8 years ago

Yep, the name is no big deal though, I think. :)

On 17 Dec 2015, at 18:09, Thomas Hempel notifications@github.com wrote:

Good idea! Never hurts to have options. Guess I have to change the name then.

— Reply to this email directly or view it on GitHub https://github.com/thomashempel/AlfredGoogleTranslateWorkflow/issues/23#issuecomment-165534769.

kamoo1 commented 8 years ago

@thomashempel Google added a parameter tk to authenticate incoming requests, there is a post on how to generate tk for valid requests. https://github.com/Stichoza/google-translate-php/issues/32

http://translate.google.cn/translate_a/single?client=t&sl=auto&tl=zh-cn&dt=t&ie=UTF-8&oe=UTF-8&tk=427258.41264&q=moon

It can return a valid result now, however the program can't parse it properly.

thomashempel commented 8 years ago

@xlrtx Wow, I will try that asap.

Unfortunately my attempts to make dict.cc work failed as they do not provide any kind of API afaik.

fns commented 8 years ago

Any progress so far? What about integrating @Stichoza code? https://github.com/Stichoza/google-translate-php

alexreg commented 8 years ago

@thomashempel Hey, any update? :) I had an idea, which may ease the burden of rewriting this workflow: you could base it as a wrapper around the excellent trans tool, and assume this is just installed on the user system. Of course, the project will require a rename then, but that's details.

gmile commented 8 years ago

@alexreg an Alftred workflow for trans tool exists now http://www.packal.org/workflow/trans-translate-shell-workflow

fns commented 8 years ago

Hell yes, I made it :)

alexreg commented 8 years ago

@gmile, @fns Thanks a lot for this! Looks perfect.

alexreg commented 8 years ago

@fns Do you have a repo for the project, by the way? I'm wondering where you got your flag icons for, so I can customise my workflow. Also, maybe I'll submit a PR for a few minor improvements. Looks good though. :)

thomashempel commented 8 years ago

Hi guys,

First off, I have to apologise for not answering for such a long time! I have a lot of private stuff going on right now and simply don't have the time to do anything (trying to build a house).

I can't even test with the recently released Alfred 3, since I don't have the funds for the PowerPack. And no, this is not me asking for donations! ;-) Not, after I left you all out in the cold for so long.

Anyways, maybe I will get back to this in the future, but I don't want to promise anything. So in the meantime you might want to look at the translate shell workflow.

I'm still open to integrate pull requests, though. I will keep this issue open for the time being.

Thank you all for your support and all the best! Thomas

thomashempel commented 8 years ago

SURPRISE! Check out version 3.1.0. ;-)

This version uses the aforementioned google-translate-php. If you are already on the shell workflow. No hard feelings. :)

Please let me know, if this works for you now. So I can at least close this issue.

Best wishes, Thomas

alexreg commented 8 years ago

@thomashempel Thanks, works nicely! One small bug though: If I just give the output language, as should be allowed (e.g. tr es Hello) then the result is Array...