Jump to content

Polyglot - yet another Google Translate workflow


Recommended Posts

Posted (edited)

Anyway, the network problem. It that line (105:17) in `google-translate-api/index.js` catch the query errors. In logs (Alfred preference => Toggle debugging mode => log [all information]) should be more detail information... Could you get it..

 

Edited by bikeNik
Posted
1 hour ago, bikeNik said:

Anyway, the network problem. It that line (105:17) in `google-translate-api/index.js` catch the query errors. In logs (Alfred preference => Toggle debugging mode => log [all information]) should be more detail information... Could you get it..

 

 

 

Starting debug for 'Google Translate'

[2018-10-18 13:22:23][input.scriptfilter] Queuing argument ''
[2018-10-18 13:22:23][input.scriptfilter] Queuing argument 't'
[2018-10-18 13:22:23][input.scriptfilter] Queuing argument 'te'
[2018-10-18 13:22:23][input.scriptfilter] Queuing argument 'tes'
[2018-10-18 13:22:23][input.scriptfilter] Queuing argument 'test'
[2018-10-18 13:22:24][input.scriptfilter] Script with argument 'test' finished
[2018-10-18 13:22:24][input.scriptfilter] {
	"items": [
		{
			"title": "Error: ",
			"subtitle": "Activate this item to try again. | ⌘L to see the stack trace",
			"autocomplete": "",
			"icon": {
				"path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
			},
			"valid": false,
			"text": {
				"largetype": "Error\n    at /usr/local/lib/node_modules/alfred-polyglot/node_modules/google-translate-api/index.js:105:17\n    at process._tickCallback (internal/process/next_tick.js:68:7)",
				"copy": "Error\n    at /usr/local/lib/node_modules/alfred-polyglot/node_modules/google-translate-api/index.js:105:17\n    at process._tickCallback (internal/process/next_tick.js:68:7)"
			}
		}
	]
}

 

Posted
7 hours ago, Nikersify said:

 

Did you install node.js?

Ah, I suspected that was the issue. I haven't, because I don't really know what it does. Are there any security issues with it? I've heard javascript isn't quite safe.

Posted (edited)
On 10/19/2018 at 5:53 PM, bivalvegruff said:

I haven't, because I don't really know what it does.

 

It's a JavaScript interpreter/platform. It does the same thing as Python and Ruby and Perl, just they are included with macOS.

 

In any case, this workflow won't run without Node…

 

On 10/19/2018 at 5:53 PM, bivalvegruff said:

Are there any security issues with it? I've heard javascript isn't quite safe.

 

The security issues aren't relevant to workflows, and JavaScript is perfectly safe. The way webbrowsers run it causes the problems. So again, not relevant.

Edited by deanishe
speling
Posted

Update v1.2.1

 

I've pushed a new version of the workflow to npm, you can upgrade by running

$ npm install -g alfred-polyglot

Notable changes since v1.2.0:

- Fixed tkk regexp not matching, which should resolve the weird google-translate-api errors

 

This should fix it for you @Zondebok, let me know if it does :)

Posted (edited)

 

Got this error again today in google-translate-api/index.js:105: 17

In my case err.stack looks like:

"HTTPError: Response code 503 (Service Unavailable)
    at stream.catch.then.data (/Users/bikenik/.npm-global/lib/node_modules/alfred-polyglot/node_modules/got/index.js:123:13)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)"

Google message is: 

Quote

Our systems have detected unusual traffic from your computer network. This page checks to see if it's really you sending the requests, and not a robot.

 

So that can't be resolved by updating the token (TKK). I couldn't come up with a solution other than changing my IP using VPN service. or with proxy google-translate-api/issues/70#i. or dedicated IP.

Edited by bikeNik
  • 1 month later...
Posted
On 10/16/2018 at 10:37 PM, Zondebok said:

Installed successfully, but I get the following when trying to do any translation

image.thumb.png.1c27ba01adef9df14bb11d3b1be0fbae.png

 

I have also this error except for next_tick.js:77:7

 

the logs are these:

Quote

[2018-12-01 19:01:50][input.scriptfilter] Queuing argument ''
[2018-12-01 19:01:50][input.scriptfilter] Script with argument '' finished
[2018-12-01 19:01:50][input.scriptfilter] {
    "items": [
        {
            "title": "Translate '...'"
        }
    ]
}
[2018-12-01 19:01:50][input.scriptfilter] Queuing argument 'h'
[2018-12-01 19:01:51][input.scriptfilter] Queuing argument 'he'
[2018-12-01 19:01:51][input.scriptfilter] Queuing argument 'hel'
[2018-12-01 19:01:51][input.scriptfilter] Queuing argument 'hell'
[2018-12-01 19:01:51][input.scriptfilter] Queuing argument 'hello'
[2018-12-01 19:01:52][input.scriptfilter] Script with argument 'hello' finished
[2018-12-01 19:01:52][input.scriptfilter] {
    "items": [
        {
            "title": "Error: ",
            "subtitle": "Activate this item to try again. | ⌘L to see the stack trace",
            "autocomplete": "",
            "icon": {
                "path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
            },
            "valid": false,
            "text": {
                "largetype": "Error\n    at /usr/local/lib/node_modules/alfred-polyglot/node_modules/google-translate-api/index.js:105:17\n    at process.internalTickCallback (internal/process/next_tick.js:77:7)",
                "copy": "Error\n    at /usr/local/lib/node_modules/alfred-polyglot/node_modules/google-translate-api/index.js:105:17\n    at process.internalTickCallback (internal/process/next_tick.js:77:7)"
            }
        }
    ]
}

 

Any idea on what's happening? I am on Alfred 3.7 and Macos Mojave 10.14.1

 

Thanks in advance!

Posted

Hi, thank you for your quick answer.

 

I don't think that's the point. I disconnected from my network (cable and wi-fi) and connected to the internet tethering my cell-phone connection. Then flushed DNS Cache in my Mac. Despite that, I keep having the same issue.

Posted (edited)

@Xusqui

 

1 hour ago, Xusqui said:

I disconnected from my network (cable and wi-fi) and connected to the internet tethering my cell-phone connection.

 

To rule out the errors related to Google's protections - try to go into this link:

 

https://translate.google.com/translate_a/single?client=t&amp;sl=auto&amp;tl=en&amp;hl=en&amp;dt=at&amp;dt=bd&amp;dt=ex&amp;dt=ld&amp;dt=md&amp;dt=qca&amp;dt=rw&amp;dt=rm&amp;dt=ss&amp;dt=t&amp;ie=UTF-8&amp;oe=UTF-8&amp;otf=1&amp;ssel=0&amp;tsel=0&amp;kc=7&amp;q=Hello world&amp;tk=535281.958536

 

You should get the text file with JSON data, otherwise, you'll get the error - kind of 503 or another with some message from Google API.

Edited by bikeNik
Posted (edited)

Hi, thank you again...

 

I get a .json file (f.txt.json) with the content:

 

Quote

[[["Hello world","Hello world",null,null,0]],null,"en",null,null,null,0.88929719,null,[["en"],null,[0.88929719],["en"]]]

 

connected to my LAN

 

Is it right?

Edited by Xusqui
further information
Posted

I uninstalled it with 

 

Quote

npm rm -g alfred-polyglot

 

no errors

 

Now when I try to reinstall it again I got a lot of errors in the npm instance...

Posted

Ok... I completely uninstalled Node.js and npm and reinstalled again (10.14.1 for node and 6.4.1 for npm)

 

I tried to install and now npm won't give me any errors, but the installation does:

 

Quote

$ sudo /usr/local/bin/npm install -g alfred-polyglot

 

> alfred-polyglot@1.2.1 postinstall /usr/local/lib/node_modules/alfred-polyglot

> alfy-init

 

{ Error: Command failed: alfred-link

Error: Alfred preferences not found at location /Users/franciscofernandezcano/Library/Preferences/com.runningwithcrayons.Alfred-Preferences-3.plist

    at pathExists.then.exists (/usr/local/lib/node_modules/alfred-polyglot/node_modules/resolve-alfred-prefs/index.js:15:10)

 

    at Promise.all.then.arr (/usr/local/lib/node_modules/alfred-polyglot/node_modules/execa/index.js:201:11)

    at process._tickCallback (internal/process/next_tick.js:68:7)

  code: 1,

  killed: false,

  stdout: '',

  stderr:

   'Error: Alfred preferences not found at location /Users/franciscofernandezcano/Library/Preferences/com.runningwithcrayons.Alfred-Preferences-3.plist\n    at pathExists.then.exists (/usr/local/lib/node_modules/alfred-polyglot/node_modules/resolve-alfred-prefs/index.js:15:10)\n',

  failed: true,

  signal: null,

  cmd: 'alfred-link',

  timedOut: false }

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! alfred-polyglot@1.2.1 postinstall: `alfy-init`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the alfred-polyglot@1.2.1 postinstall script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

 

npm ERR! A complete log of this run can be found in:

npm ERR!     /Users/franciscofernandezcano/.npm/_logs/2018-12-02T13_02_34_140Z-debug.log

 

I PM the npm log.

Posted

Ok... That's what I had when I didn't make SUDO, I got EACCESS errors.

 

So I have followed the instructions here: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally and now I can install and uninstall globally without sudo: Now the output when installing Alfred-polyglot seems to be fine:

 

Quote

$ npm install -g alfred-polyglot

 

> alfred-polyglot@1.2.1 postinstall /Users/franciscofernandezcano/.npm-global/lib/node_modules/alfred-polyglot

> alfy-init

 

+ alfred-polyglot@1.2.1

added 148 packages from 59 contributors in 10s

 

But still getting the same error.

 

As I have installed a node versión manager (n), I have tried different versions of node, and I get that error in all the versions I have tried.

 

Any other suggestions?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...