The Dictionary App has a very cool experience on MacOSX. But I have to install dictionaries to use. Is it possible to bind it to Google Translate?
Thanks!
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.
Sign up to join this communityThe Dictionary App has a very cool experience on MacOSX. But I have to install dictionaries to use. Is it possible to bind it to Google Translate?
Thanks!
Unfortunately it doesn't appear to be possible, or at least straightforward. As an alternative, you may want to consider creating an OS X Service that opens Google Translate in a browser window, for any highlighted word or phrase you have selected.
If this sounds suitable, follow the procedure below:
Automator
app from your Applications
folderService
as the type of document and click Choose
Run AppleScript
action from the list on the left into the area labelled 'Drag actions or files here to build your workflow'Copy the script below and paste it into the Run Applescript
action:
on run {input, parameters}
set phrase to input as string
set phrase to quoted form of phrase
set ui_lang to "en"
set from_lang to "en"
set to_lang to "zh-CN"
do shell script "open 'https://translate.google.com/?hl='" & ui_lang & "'&sl='" & from_lang & "'&tl='" & to_lang & "'&text='" & phrase
end run
Your window should look like the following:
There are three values that you may want to change in the above script:
ui_lang
- the language used for the page interfacefrom_lang
- the source languageto_lang
- the destination languageChange one or more of these to achieve the desired translation. To find the correct language parameters, refer to the Language Reference. In the example above en
refers to English
, and zh-CN
to Chinese (Simplified).
After making your changes, click File
> Save...
and in the panel that appears type a suitable name (e.g. Translate English to Chinese
).
After saving your workflow above, you can make use of your translation service with one of the following two methods:
1. The Service Menu method
Services
and Translate English to Chinese
(or the name you gave your Service when saving it):2. The Contextual Menu method
Services
then Translate English to Chinese
(or your custom named Service):Whichever method you use, a browser window should appear with your translated text:
This one does everything like the soulcake's answer but if the translater's url is already present - loads new translation in the same tab
on run {input, parameters}
set phrase to input as string
set ui_lang to "en"
set from_lang to "en"
set to_lang to "ru"
set theBaseUrl to "https://translate.google.com/"
set theUrl to theBaseUrl & "?hl=" & ui_lang & "&sl=" & from_lang & "&tl=" & to_lang & "&text=" & phrase
tell application "Google Chrome"
activate
if (count every window) = 0 then
make new window
end if
set found to false
set theTabIndex to -1
repeat with theWindow in every window
set theTabIndex to 0
repeat with theTab in every tab of theWindow
set theTabIndex to theTabIndex + 1
if theTab's URL starts with theBaseUrl then
set found to true
exit repeat
end if
end repeat
if found then
exit repeat
end if
end repeat
if found then
set URL of theTab to theUrl
set theWindow's active tab index to theTabIndex
set index of theWindow to 1
else
tell window 1 to make new tab with properties {URL:theUrl}
end if
end tell
end run