MacOS – Automator Service with Google Translate

automatormacosscript

I set up an Automator Service that receives selected text and then runs a simple shell script to pass the text to open google translate:

open https://translate.google.com/#auto/en/"$@"

It opens google translate just fine, but doesn't pass the text along with it. How can I fix?

google translate service

Best Answer

It worked for me as long as pass input was set to as arguments. You could try restarting or creating a new identical service like that.

You have to URL encode the input though:

open https://translate.google.com/#auto/auto/$(ruby -rcgi -e 'print CGI.escape(STDIN.read)')

Or if you don't want to use ruby:

xxd -p | tr -d '\n' | sed 's/\(..\)/%\1/g'