You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JayBrown edited this page Feb 22, 2016
·
4 revisions
Translate Shell can also be run from an AppleScript, either directly or as an Automator Service, with the do shell script command.
It is important to note that AppleScript uses the Bourne Shell (sh) for shell commands, not zsh or bash, which means that the trans command will not work out of the box. Exporting the path before the trans command can be a remedy.
Example 1: in the following AppleScript example trans is run from an AppleScript and will translate a given text (theText) into English:
do shell script "export PATH=\"/usr/local/bin:$PATH\";/usr/local/bin/trans -b :en " & quoted form of theText
Example 2: three lines of AppleScript code for direct testing in ScriptEditor:
set theText to "Das ist super!"
set theTranslation to (do shell script "export PATH=\"/usr/local/bin:$PATH\";/usr/local/bin/trans -b :en " & quoted form of theText)
theTranslation
Note: if you don't want to export the path, AppleScript will also work if you create a symlink to the gawk binary in /usr/bin.