第一步:
.首先打开 Automator ,新建文稿,文稿类型选"服务",在左上的搜索框输入:"apple",找到"运行 AppleScript"项后双击,在右侧的编辑区,删除默认添加的代码,粘贴以下代码:
on run {input, parameters}
set output to "https://translate.google.cn/#auto/zh-CN/" & urldecode(input as string)
return output
end run
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
如下图所示
apple javascript
上述代码里 "/#auto" 表示自动检测语言,"/zh-CN/" 表示翻译为简体中文,你可以根据你自己的需求,改为"中译英"、"日译繁中"、"德译法"等等,具体的语言代码请浏览器打开 谷歌翻译选择语言后在地址栏获取。
第二步:
接下来继续搜索"菜单",找到"网站弹出式菜单"项双击,在右侧的编辑区可以修改部分设置,比如大小选择"自定",个人建议大小设为 720×480 ,位置选择"鼠标指标"。最后保存,起一个名字,这里我取Google translate。
如下图:
website popup
custom pop up size
运行一遍,然后出现这样的界面