Translate text with Automator on OSX

AUTOMATOR SERVICE

If you find yourself in the situation of handling texts in English that you have to translate continuously, or at least know the meaning that it has even if you later give the correct meaning to the translation, today we bring you a simple way to do it using the app "automator»From OSX.

What we want to achieve is an action by the system, so that if we want to have the translation of a certain text we do not have to go to the Google page, search for the Google translator, then copy and paste the text in the box and give it to translate. With this simple tutorial, our OSX system will do that job for us by automatically giving us the translation in a Safari window.

We start by running the "Automator" application searching for it from Spotlight, for example. When we have it open, we will choose in the main window to perform an action on "Service". Next, in the search engine on the left we look for "Run an AppleScript" and drag it to the window on the right.

The next step is to delete the content and copy the prepared script that I attach below to do the action we want, which in this case, is that when we select a text in English, when we click the right mouse button, the order this script and he just go to Google translate, open it, make the translation and give it to us.

The script that we must paste is:

SCRIPT TRANSLATION

on run {input, parameters}
set theURL to «http://www.google.com/translate_t?langpair=en%7es&text=» & input
tell application «Safari» to make new document with properties {URL: theURL}
end run

When we finish, we give it to save and we give it a logical name such as "TRANSLATE TEXT". Now we only have to select a text in English within the system or Safari, give the right button of the mouse, we will see how the name of the script that we have created appears and when we click it, it will open Safari and give us the translation.

TRANSLATION EXAMPLE

More information - Print documents from anywhere with DropBox


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Juan said

    and to remove that action and make it appear "TRANSLATE TEXT"

    1.    PETER RHODES MARTIN said

      What do you mean Juan?

      1.    gtv said

        Here is one that works perfectly for me without modifying the format:

        on run {input, parameters}
        set theURL to «http://www.google.com/translate_t?langpair=en%7es&text=» & input
        tell application «Safari» to make new document with properties {URL: theURL}
        end run

        link to source:
        http://www.todosobremimac.com/files/Traducir-Textos-Con-Automator.php

  2.   Juan said

    and to remove that action and not appear "TRANSLATE TEXT"

  3.   Aldo graziani said

    It doesn't work for me.

    "Expression expected" and starts the error in "http://www.google.com/translate_t?langpair=en%7es&text="

    I would find this script very useful

    1.    Miguel Angel Juncos said

      Delete the quotation marks in both "http ..." and in "Safari" and put them yourself, if you paste them directly as they are formatted, it gives an error.

      Then look to see that there is only one end run. It works well for me.

      1.    carmen said

        I had that same error, I put the quotes myself and now it works perfectly. Thanks

    2.    PETER RHODES MARTIN said

      Miguel is right. It is proven and works perfectly. All the best. Thanks Miguel!

  4.   Aldo graziani said

    Thank you very much Miguel Angel!
    Now start the script but I have a new problem ...
    It only translates the addresses I copy, not the text.
    For the latter, I open a new safari window and leave it blank without doing anything else.
    Does it only happen to me?

  5.   HRPS said

    Hello, It doesn't work for me. It just takes me to the Google page ..

  6.   Aldo graziani said

    Hello again.

    I have discovered that in the end the text also translates it for me.

    What happens is that there are times when we copy a text that is "entirely" in English, but if it contains a phrase in any other language, it does not recognize it and takes us to a new blank safari window.

    I think that the parameter to change to be able to translate any language would be the one that I have put in quotes:

    http://www.google.com/translate_t?langpair=«» »» In »» »» »% 7es & text =

    In safari "directions" I get "auto" when I select automatic mode or language detection from google translator, selecting the input language, but when using that command in the script, the latter does not understand it and ignores it.

    I would like to share this message with someone knowledgeable in the field to see if they could add that command so that the script, "from my point of view", would be more complete.

    Greetings to all and thanks for sharing this method to translate webs in a more comfortable way.

  7.   envarrosa said

    Thanks, it worked perfectly. The only but is that a new window opens for each word you search (and they are not pop-ups). But anyway, a great contribution. Thank you very much again!

    1.    Mario said

      With this other code you can force a new tab to open:

      on run {input, parameters}
      set theURL to «https://translate.google.com/?text=» & input & «# auto / es /» & input
      tell application “Safari”
      activated
      try
      tell window 1 to set current tab to make new tab with properties {URL: theURL}
      on mistake
      open location the URL
      end try
      end tell
      end run

      on new_tab ()
      tell application “Safari” to activate
      tell application “System Events”
      tell process “Safari”
      click menu item “New Tab” of menu “File” of menu bar 1
      end tell
      end tell
      end new_tab

      Greetings.

  8.   ander said

    Very big! Thank you thousands.

  9.   Luis Miguel Mora Gutierrez said

    And what to do with the new Yosemite? I have tried yours and it does not work for me, apart from the fact that the interface of the spotlight is different. Thanks

  10.   Bill said

    Does anyone know of any app or some way that the word is translated automatically, when you put the cursor on it, how does the Google translator bar work ... when one is browsing a page in another language ...

    It is incredible how Apple does not have something that is as necessary and useful as that ...

    Thank you very much if someone can contribute something ..

  11.   Pedro said

    someone could have it for captain because it is not working with these commands apparently it does not work in that new ox

  12.   frameworks said

    and how it works or what would be the change for Chrome

  13.   Keiner Chará  (@KeinerChara) said

    Excellent contribution, does anyone know how Chrome can be opened instead of Safari?

  14.   leo said

    in captain apparently it does not work, does anyone know how to adapt it?

  15.   Jesus Martinez Jimenez said

    hi, iBooks doesn't work for me, I just don't get the option when I click the right button. What I can do?

    1.    Mario said

      iBooks has its own contextual menus so it is normal that you do not get it, the closest thing I can think of is to install a Spanish - English dictionary (which I said is not wrong and it comes by default), and use the "Consult" option of the context menu once you have selected the word.

  16.   rodrigo olivarez said

    Hello good! I need the entire site to be translated for me automatically… is it good for me? I was reading that it only translates selected words, can it be?

  17.   VICELENA23 said

    Excellent contribution made by MARIO in my Sierra it works perfectly, you just have to put the »» by hand to make it work, it opens in the same Safari session.

  18.   Mark said

    Hello friend, I see that you are a Mac specialist. I want to ask you a favor, if possible, to see if you can help me. I had Mac Lion 10.7 installed (I am not one of those who are after updates or new operating systems, while the one I have works for me), but a few days ago I did something unusual, looking for a necessary app. When I enter the App Store, an app comes out of nowhere (I thought) Os Sierra, I think it was an interesting application because I saw that it had certain utilities. so I gave him download, in my distraction and I went to sleep. When I returned everything was downloaded and ready to install, I tried to enter the machine but it did not give me options, then I understood it was a new operating system. The Mac OS Sierra is working relatively well, but it won't let me connect to the internet with a 3G modem from movistar (Venezuela), brand E1756, it doesn't even recognize it even though I downloaded the Drivers for Mac OS… what can I do? Thanks in advance….

  19.   Daniel curutchet said

    Hi how are things ? I run into the same problem as others. I have El Capitan installed and it does not respond to the Script mentioned here and apart I would need to open it under Google Chrome Please. Thank you in advance.

  20.   Alexander melo said

    Hello, good morning, I have the same problem as Daniel, I have Catalina installed and the script has not responded. I have already corrected the quotes of the script and when testing it inside the automator it seems to be fine, but in the services it does not come out. I appreciate the help. Thanks a lot.