Created
November 2, 2016 17:37
-
-
Save peterwooley/5b7eb9d66d53103ae464f380ea4fb652 to your computer and use it in GitHub Desktop.
Run this AppleScript in an Automator service to open selected text in Google Translate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Modified from http://scriptingosx.com/2016/01/build-a-google-translate-service/ | |
on run {input, parameters} | |
set theText to input as string | |
set oldDelims to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to {return & linefeed, return, linefeed, " | |
", character id 8233, character id 8232} | |
-- list of line break chars from http://stackoverflow.com/questions/12546253/how-to-replace-n-in-applescript#12546965 | |
set splitText to text items of theText | |
set AppleScript's text item delimiters to {space} | |
set theText to splitText as text | |
set AppleScript's text item delimiters to oldDelims | |
tell application "Safari" | |
activate | |
set d to make new document with properties {URL:"https://translate.google.com/#auto/en/" & theText} | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No issue in macOS 11.3.1 with both the suggested apple scripts and the "Workflow receives current: text" option. Just make sure you create a Quick Action not a Workflow.