Hi!
The following script should check if the selected text in Safari is English. If so, it should open http://translate.google.com/translate_t?hl=en#en|ko| with the text translated to Korean. If it’s not English, it should open http://translate.google.com/translate_t?hl=en#ko|en| and translate the text to English. But it doesn’t! And I can’t understand why…
tell application "Safari"
set transText to do JavaScript "getSelection();" in document 1
set theChars to the characters of transText
if theChars contains "a" or "e" or "i" or "o" or "u" then
open location "http://translate.google.com/translate_t?hl=en#en|ko|" & transText
else
open location "http://translate.google.com/translate_t?hl=en#ko|en|" & transText
end if
end tell
Any insight is greatly appreciated!
If you need some Korean text to experiment on, try http://www.google.com/search?client=safari&rls=en-us&q=한글&ie=UTF-8&oe=UTF-8.