Jump to content
Nikersify

Polyglot - yet another Google Translate workflow

Recommended Posts

Try the command at the end of your pastebin, it should fix the permissions for /Users/account/.config:

sudo chown -R $USER:$(id -gn $USER) /Users/account/.config

 

Share this post


Link to post
7 hours ago, Nikersify said:

sudo chown -R $(whoami) /usr/local/lib/node_modules/
/usr/local/bin/npm install -g alfred-polyglot

 

This made it work for me - awesome workflow! Thank you so much! 

Edited by Milly Bays

Share this post


Link to post

Great work! Thanks, it's very handy. 
 

I've also disabled the default "Translate" Web Search provided by Alfred – there is no need for it anymore. :)

Share this post


Link to post

Update v1.1.3

 

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

$ npm install -g alfred-polyglot

Notable changes since v1.0.0:

 

v1.1.2

- Fixed update notifier text not being shown

 

v1.1.1

- Added quicklook url to the translate command - press your quicklook key (Shift by default) to see the translation on translate.google.com

- Fixed languages with dashes not being detected (thanks @noelneb)

- Fixed words like sTOłek or FROMage triggering the from/to language parser incorrectly

- Added esperanto language flag

Edited by Nikersify
new version

Share this post


Link to post

I keep getting this error message during install.  It does install but when I try to run the workflow I get an : HTTP Error 403: Forbidden.  MY Key is set right becaeu when I set it incorrectly I get a bad key error.

 

Herre is the install NPM Error message I get.   I would appreciate any help.

 

This error says my Alfred preferences file are not found at the top but the file definitely exists.  

 

[DIVINCEM-MAC] /usr/local…ib/node_modules/npm > sudo /usr/local/bin/npm install -g alfred-polyglot

> alfred-polyglot@1.1.5 postinstall /usr/local/lib/node_modules/alfred-polyglot
> alfy-init

{ Error: Command failed: alfred-link
Error: Alfred preferences not found at location /Users/divincem/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 <anonymous>

    at Promise.all.then.arr (/usr/local/lib/node_modules/alfred-polyglot/node_modules/execa/index.js:201:11)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
  code: 1,
  killed: false,
  stdout: '',
  stderr: 'Error: Alfred preferences not found at location /Users/divincem/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    at <anonymous>\n',
  failed: true,
  signal: null,
  cmd: 'alfred-link',
  timedOut: false }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! alfred-polyglot@1.1.5 postinstall: `alfy-init`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the alfred-polyglot@1.1.5 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/divincem/.npm/_logs/2018-04-01T23_31_41_596Z-debug.log
 

Edited by mikedvzo

Share this post


Link to post
7 hours ago, Nikersify said:

@mikedvzo It's likely to be an error due to running npm install with sudo. Try running the install command without sudo and if that fails go through the steps described here (option two).

The install succeeded without errors but the Workflow still throws the following errors.  I checked the GCP and said the Translation API was enabled.

 

Starting debug for 'Translate service'

 

[2018-04-02 08:51:30][ERROR: input.scriptfilter] Code 1: 08:51:30 workflow.py:2225 DEBUG    Workflow version : 1.1.2

08:51:30 workflow.py:1628 DEBUG    Reading settings from `/Users/divincem/Library/Application Support/Alfred 3/Workflow Data/com.sozora.google-translate/settings.json` ...

08:51:30 workflow.py:2514 DEBUG    Update check not due

08:51:30 workflow.py:1859 DEBUG    Loading cached data from : /Users/divincem/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/com.sozora.google-translate/__workflow_update_status.cpickle

08:51:30 workflow.py:2444 DEBUG    update_data : {u'available': False}

08:51:30 workflow.py:2633 DEBUG    Got password : com.sozora.google-translate:google_translate_api_key

08:51:30 workflow.py:2633 DEBUG    Got password : com.sozora.google-translate:google_translate_api_key

08:51:30 workflow.py:2243 ERROR    HTTP Error 403: Forbidden

Traceback (most recent call last):

  File "/Users/divincem/Dropbox/Sync/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.F91D9C36-8081-42D3-A160-36CD90205402/workflow/workflow.py", line 2236, in run

    func(self)

  File "base_translate.py", line 102, in main

    translations = api.get_translations()

  File "/Users/divincem/Dropbox/Sync/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.F91D9C36-8081-42D3-A160-36CD90205402/google_translate.py", line 102, in get_translations

    max_age=MAX_AGE_CACHE)

  File "/Users/divincem/Dropbox/Sync/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.F91D9C36-8081-42D3-A160-36CD90205402/workflow/workflow.py", line 1865, in cached_data

    data = data_func()

  File "/Users/divincem/Dropbox/Sync/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.F91D9C36-8081-42D3-A160-36CD90205402/google_translate.py", line 50, in __get_translations

    raise e

HTTPError: HTTP Error 403: Forbidden

08:51:30 workflow.py:2267 DEBUG    Workflow finished in 0.325 seconds.

Share this post


Link to post

Looks like I fixed it.  I did some searching and it appears since I had set the Google Translate API up along time ago the Billing was not tied toe the API and I had to enable it under Quotas.  Thanks it works great now.  ? 

Share this post


Link to post
3 hours ago, mikedvzo said:

Looks like I fixed it.  I did some searching and it appears since I had set the Google Translate API up along time ago the Billing was not tied toe the API and I had to enable it under Quotas.  Thanks it works great now.  ? 

 

I think you've installed a different workflow, no problem though! ?

Share this post


Link to post

This workflow can't be synced as it is installed out of synced folder. Is it possible to install this workflow in synced folder instead of "/usr/local/lib/node_modules/alfred-polyglot"?

Share this post


Link to post
2 hours ago, lofi said:

This workflow can't be synced as it is installed out of synced folder. Is it possible to install this workflow in synced folder instead of "/usr/local/lib/node_modules/alfred-polyglot"?

 

Copying the directory "/usr/local/lib/node_modules/alfred-polyglot" to your synced folder manually should do the trick, though note that you will have to do it every time you update the workflow.

Share this post


Link to post
On 4/2/2018 at 12:07 PM, Nikersify said:

 

I think you've installed a different workflow, no problem though! ?

Same workflow just act I had the API setup along time ago with a different workflow and had forgotten 

Share this post


Link to post

Thanks for making this workflow.

 

FYI, "undefined-->English" is displayed when traditional Chinese characters are entered. The workflow does successfully fetch the translation from Google, though.

Share this post


Link to post

Update v1.2.0

 

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.1.5:

 

v1.2.0

- Fixed the workflow translating to the same language as it is translating from (more info)

- Translating from chinese simplified/traditional no longer shows undefined (thanks @etm001!)

Share this post


Link to post

Hi there,

 

I was using your workflow on my old MacBook, and since it was working perfectly I wanted to install it on my new MBPro. I remember that on my first installation, I got some issues and I just have to stupidly follow the commands you advised to Mohammad in this topic.

 

I first tried the command itself given in the installation process (workflow was already synced through Dropbox). Since it was not working, I deleted the workflow and downloaded it again from Github, then I installed it and try again the first command given in the installation process.

Then I got several errors, so I remember I went too fast... I installed node.js and I also used the "csrutil disable" command to allow the access to some folders (some errors were showing that I didn't have access to edit usr folder), then I followed again what you guys explained to Mohammad to activate the workflow.

 

Is it related to the fact that I use a sync folder (Dropox) ? Did I fucked it up by using commands I don't understand at all ? ? 

 

Note : between each steps, I tried the workflow and it never worked when it came to translate (display a red ! with ERROR in Alfred)

 

The attached file is the error I got while using the workflow, and following is the full error log I got with the Terminal :

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'i',
1 verbose cli   '-g',
1 verbose cli   'alfred-polyglot' ]
2 info using npm@6.4.1
3 info using node@v8.12.0
4 verbose npm-session b9c662e2b42691cf
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 timing stage:rollbackFailedOptional Completed in 11ms
8 timing stage:runTopLevelLifecycles Completed in 14ms
9 verbose stack Error: Invalid tag name "alfred-polyglot": Tags may not have any characters that encodeURIComponent encodes.
9 verbose stack     at invalidTagName (/usr/local/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:87:15)
9 verbose stack     at fromRegistry (/usr/local/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:290:13)
9 verbose stack     at resolve (/usr/local/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:77:12)
9 verbose stack     at npa (/usr/local/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:48:10)
9 verbose stack     at /usr/local/lib/node_modules/npm/lib/install/deps.js:209:14
9 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:52:35
9 verbose stack     at Array.forEach (<anonymous>)
9 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:52:11
9 verbose stack     at Array.forEach (<anonymous>)
9 verbose stack     at asyncMap (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:51:8)
9 verbose stack     at exports.getAllMetadata (/usr/local/lib/node_modules/npm/lib/install/deps.js:206:3)
9 verbose stack     at Installer.loadArgMetadata (/usr/local/lib/node_modules/npm/lib/install.js:360:3)
9 verbose stack     at Installer.readGlobalPackageData (/usr/local/lib/node_modules/npm/lib/install.js:658:8)
9 verbose stack     at Array.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
9 verbose stack     at LOOP (/usr/local/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14)
9 verbose stack     at chain (/usr/local/lib/node_modules/npm/node_modules/slide/lib/chain.js:20:5)
10 verbose cwd /Users/antoine
11 verbose Darwin 18.0.0
12 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "-g" "alfred-polyglot"
13 verbose node v8.12.0
14 verbose npm  v6.4.1
15 error code EINVALIDTAGNAME
16 error Invalid tag name "alfred-polyglot": Tags may not have any characters that encodeURIComponent encodes.
17 verbose exit [ 1, true ]

I miss that workflow, please help !

Capture d’écran 2018-10-12 à 09.10.25.png

Edited by CptTonio

Share this post


Link to post
On 10/12/2018 at 8:20 AM, CptTonio said:

Did I fucked it up by using commands I don't understand at all ?

 

This is what has happened. And please don't swear on the forum.

 

You appear to have copied and pasted some command and messed it up:

 

Quote

9 verbose stack Error: Invalid tag name "alfred-polyglot"

 

That "alfred-polyglot" isn't ASCII. When I paste it into Python, I get:


'alfred\xef\xbb\xbf\xef\xbb\xbf\xef\xbb\xbf-polyglot\xef\xbb\xbf\xef\xbb\xbf\xef\xbb\xbf' instead of 'alfred-polyglot'.

 

Try typing the commands instead. Or if you typed them, try copy and pasting them. The commands must be ASCII. No "smart" hyphens or other punctuation.

 

Share this post


Link to post

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
×