Apple - Is it possible to bind my Mac OSX Dictionary.app to Google Translate?
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:
Creating a translation Service
- Open the
Automator
app from yourApplications
folder - Select
Service
as the type of document and clickChoose
- In the window that appears, click the search field and type 'AppleScript'
- Drag and drop the
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 language
Change 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
).
Using the translation Service
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
- Highlight a word or phrase in any application
- Click the Application Menu to the right of the Apple icon (), then click
Services
andTranslate English to Chinese
(or the name you gave your Service when saving it):
2. The Contextual Menu method
- Highlight a word or phrase in any application
- Right-click the text and select
Services
thenTranslate English to Chinese
(or your custom named Service):
Whichever method you use, a browser window should appear with your translated text: