2010年4月12日星期一

添加一个”Services"-Translate with Google

依照笑来老师的教程添加了几个Services
今天试图添加一个Translate with Google的时候却遇到了点问题

Google translate的Prefix是这样的
"http://translate.google.cn/#auto|zh-CN|"
按教程到了Display Webpages步骤却会将网址编码转换为
"http://translate.google.cn/%23auto%7Czh-CN%7C"

问题在于Google translate不支持编码后的‘#’

研究了下于是用AppleScript解决

以下是代码
on run {input, parameters}
set thePre to "http://translate.google.cn/#auto|zh-CN|"
set theUrl to thePre & input
tell application "Safari"
activate
make new document
set the URL of front document to theUrl
end tell
return input
end run

没有评论:

发表评论