Google translate client for OS X

10

8

I'm using Translate Client on Windows. This tool instantly get translation of selected text in any application by double press Ctrl What are alternatives for Mac OS X?
Good implementation would be as in Dictionary (select word Command+Control+D) enter image description here

UPDATE:

  1. http://www.yuriev.info/translator/translator.zip
    Article about this enter image description here

diimdeep

Posted 2011-06-13T10:02:30.987

Reputation: 762

Question was closed 2016-04-25T16:52:20.703

Are you looking for specific features, or does a basic service hacked together in 5 minutes suffice? – Daniel Beck – 2011-06-13T10:09:56.740

I'm looking for program that give me easy way to use google translate from any place in osx like it do translateclient.com under Windows. – diimdeep – 2011-06-13T10:15:23.810

Just a hint, the people most qualified to answer your question likely don't even have a Windows machine. "like this other thing you've never heard of and can't even try yourself" is therefore not a good idea if you want good answers. – Daniel Beck – 2011-06-13T10:25:02.253

1Google has *deprecated* the Google Translate API, so there's unlikely to be nicer solutions than the one I suggested, that will still work in 2012. – Daniel Beck – 2011-06-13T13:11:15.050

2

UPDATE June 3: In the days since we announced the deprecation of the Translate API, we’ve seen the passion and interest expressed by so many of you, through comments here (believe me, we read every one of them) and elsewhere. I’m happy to share that we’re working hard to address your concerns, and will be releasing an updated plan to offer a paid version of the Translate API. Please stay tuned; we’ll post a full update as soon as possible. http://googlecode.blogspot.com/2011/05/spring-cleaning-for-some-of-our-apis.html

– diimdeep – 2011-06-13T13:15:29.143

Nice find. You should post this as answer, even though you might need to pay for Translate. – Daniel Beck – 2011-06-13T13:19:52.457

Answers

11

Open /Applications/Automator.app, select to create a new Service, double-click Run AppleScript from the Utilities library, and enter the following script code into the text field:

on run argv
    tell application "Safari"
        make new document at end of documents
        set URL of document 1 to "https://translate.google.com/#view=home&op=translate&sl=en&tl=es&text=" & item 1 of argv
    end tell
end run

Save as Translate to Spanish.


Now you can select text in any application, and select Translate to Spanish from the context menu, or the Application » Services menu. A new Safari window will open, with the selected text as input to Google Translate.


You can assign a keyboard shortcut in System Preferences » Keyboard » Keyboard Shortcuts » Services.


Selecting from context menu (it's a submenu since I have too many applicable services, you can disable some in System Preferences):

enter image description here


The following page opens after clicking the menu item:

enter image description here

Daniel Beck

Posted 2011-06-13T10:02:30.987

Reputation: 98 421

This script doesn't work for me on macOS 10.12.4. Safari just opens a blank window. – Justin Searls – 2017-04-09T16:41:33.243

@JustinSearls Well, it worked six years ago. Note that due to the dependency of the exact URLs of a web service, this could always break (in fact, on my Mac it still works, but just opens translate.google.com with no translation). – Daniel Beck – 2017-04-09T19:57:10.713

Woow, that is very good. but it will be better if translation just appears in small popup. – diimdeep – 2011-06-13T10:47:14.647

@diimdeep That's why I asked for specific criteria. – Daniel Beck – 2011-06-13T11:04:04.810

3

I'd prefer a native application or a ⌃⌘D-style panel as well. But for now I'm using this AppleScript:

try
    tell application (path to frontmost application as text)
        set ans to text returned of (display dialog "" default answer "ja ")
    end tell

    set offs to offset of space in ans
    set i1 to text 1 thru (offs - 1) of ans
    set i2 to text (offs + 1) thru -1 of ans

    set sl to "en"
    set tl to "en"
    set z to offset of "-" in i1
    if i1 is "-" then
        set sl to "auto"
    else if z is 0 then
        set tl to i1
    else if z is (count i1) then
        set sl to text 1 thru -2 of i1
    else
        set sl to text 1 thru (z - 1) of i1
        set tl to text (z + 1) thru -1 of i1
    end if
    set base to "http://translate.google.com/#"
    set u to base & sl & "|" & tl & "|" & urldecode(i2)

    tell application "Safari"
        activate
        open location u
    end tell
end try

on urldecode(x)
    set cmd to "'require \"cgi\"; puts CGI.escape(STDIN.read.chomp)'"
    do shell script "echo " & quoted form of x & " | ruby -e " & cmd
end urldecode

The web client has some features that are essential to me, like transliterating text to the latin alphabet from other writing systems, and providing alternative translations for single words.

Extra: minimal userstyle for Google Translate.

Lri

Posted 2011-06-13T10:02:30.987

Reputation: 34 501

3

Open up Automator
Select Service
Select Utilities under Library
Select Run Shell Script
On the 'Shell:' dropdown menu, select '/usr/bin/ruby'
Type into the textbox:

require 'cgi'<br>
`open 'http://translate.google.com/#auto/en/#{CGI.escape(STDIN.read.chomp)}'`

Save the script as 'Translate to English' or whatever

Now, right clicking on any highlighted text and selecting 'Translate to English' will open up a new Google Translate page with the highlighted text translated into English.

user202543

Posted 2011-06-13T10:02:30.987

Reputation: 31

Kudos, this one actually still works. – Justin Searls – 2017-04-09T16:43:27.620

1

  • Open Automator
  • Create a new "Service"
  • Select Utilities → Library → Run Shell Script
  • Choose /usr/bin/ruby and paste this script:

    require 'cgi'
    system("open 'http://translate.google.com/#auto/en/#{CGI.escape(STDIN.read.chomp)}'")
    
  • This is what you should get:

    script interface

  • Save it under name "translate"

    Save it under name "translate"

  • Now you can translate any text:

    Translate any text

Dorian

Posted 2011-06-13T10:02:30.987

Reputation: 1 191

0

A version of EN-RU translation for Google Chrome

on run argv
    tell application "Google Chrome"
        set myTab to make new tab at end of tabs of window 1
        set URL of myTab to "http://translate.google.com/#en|ru|" & item 1 of argv
        activate
    end tell
end run

And a keyboard shortcut trick still works perfectly (El Capitan). You'll find your new service in the list of services, end of "Text" section: enter image description here

Max Lobur

Posted 2011-06-13T10:02:30.987

Reputation: 101