Aquí es un applescript acabo de poner que está trabajando para mí (10.9)
Se puede colocar en el menú de applescripts y ejecutar en los Correos electrónicos seleccionados.
La secuencia de comandos:
- Intentar agarrar la seleccione mensajes de correo electrónico en Mail.
- Enviar una Solicitud a google translate
- Convertir el resultado en HTML a texto sin formato
- Visualización temporal de un archivo de texto con la traducción.
Puede establecer el idioma original, en auto o en uno de los idiomas en el languages_code lista. Y también establecer el resultado de idioma de la lista.
No hay ninguna razón que usted no debe ser capaz de crear un servicio de uso de este script. Pero voy a dejar que usted. Sólo tenga en cuenta que para que el dispositivo funcione usted tendrá que hacer clic derecho/ctrl +clic en un mensaje del cuerpo para el servicio de menú para mostrar. O utilice el menú de Servicios.
#http://macscripter.net/viewtopic.php?id=31218
#http://macscripter.net/viewtopic.php?id=39742
#The above links are the starting points of this script which both attempt to translate text. But are broken or do not return the full text.
#This script will attampt to translate the text from the selected emails to your chosen language
property languages_code : {Afrikaans:"af", Albanian:"sq", Arabic:"ar", Belarusian:"be", Bulgarian:"bg", Catalan:"ca", Chinese:"zh-CN", Croatian:"hr", Czech:"cs", Danish:"da", Dutch:"nl", English:"en", Estonian:"et", Filipino:"tl", Finnish:"fi", French:"fr", Galician:"gl", German:"de", Greek:"el", Hebrew:"iw", Hindi:"hi", Hungarian:"hu", Icelandic:"is", Indonesian:"id", Irish:"ga", Italian:"it", Japanese:"ja", Korean:"ko", Latvian:"lv", Lithuanian:"lt", Macedonian:"mk", Malay:"ms", Maltese:"mt", Norwegian:"no", Persian:"fa", Polish:"pl", Portuguese:"pt", Romanian:"ro", Russian:"ru", Serbian:"sr", Slovak:"sk", Slovenian:"sl", Spanish:"es", Swahili:"sw", Swedish:"sv", Thai:"th", Turkish:"tr", Ukrainian:"uk", Vietnamese:"vi", Welsh:"cy", Yiddish:"yi"}
#Curl stuff
property agent : "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; en-us) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10"
property charset : "UTF-8"
property header : "Charset:" & space & charset
property theURL : "https://translate.google.com/?" #This must be https
#used to delimit the html
property snipOpen : "TRANSLATED_TEXT="
property snipClose : ";INPUT_TOOL_PATH"
#You can either set a start language or leave it at auto.
property startLang : "auto"
#set a result language
property resultLang : English of languages_code
#Ask Mail to get and process selected emails
tell application "Mail"
set theMessages to (get selection)
repeat with i from 1 to number of items in theMessages
set this_item to item i of theMessages
set thisSender to sender of this_item
set thisSubject to subject of this_item
set thisText to content of this_item as string
my translate(thisSender, thisSubject, thisText)
end repeat
end tell
(*************** SUBROUTINES *****************)
#Translate the message text and display them in a temp text file
on translate(thisSender, thisSubject, thisText)
if thisText is not "" then
#replace all spaces with "%20" for the URL to use without error
set escapedText to findReplace(thisText, space, "%20")
#send request to google and get the returned HTML
set TranslatedText to do shell script "/usr/bin/curl" & space & ¬
"-A" & space & quoted form of agent & space & ¬
"-H" & space & quoted form of header & space & ¬
"-d" & space & quoted form of ("&ie=" & charset & "&oe=" & charset & "&langpair=" & startLang & "|" & resultLang & "&text=" & escapedText) & space & quoted form of theURL
try
#Use delimiters to split the text to just get the actual result part
set txt to Split(TranslatedText, snipOpen)'s item 2
set txt to Split(txt, snipClose)'s item 1
set displayText to ¬
"Sender: " & thisSender & "<br>" & ¬
"Subject: " & thisSubject & "<br>" & "<br>" & ¬
txt
#Use Textutil to strip any other rich text or HTML code out and convert to plain text. Then open in a text document
do shell script "echo " & quoted form of displayText & "|textutil -format html -convert txt -stdin -stdout | open -f"
on error errTxt number errNum
display dialog errTxt with title "Error# " & errNum buttons {"Cancel", "OK"} default button 2 with icon 0 giving up after 0
end try
end if
end translate
on Split(txt, del)
set {otid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, del}
set txt to text items of txt
set AppleScript's text item delimiters to otid
return txt
end Split
on findReplace(theString, search_string, replacement_string)
if theString contains search_string then
set AppleScript's text item delimiters to search_string
set text_item_list to text items of theString
set AppleScript's text item delimiters to replacement_string
set theString to text_item_list as text
set AppleScript's text item delimiters to ""
end if
return theString
end findReplace