ts(){
curl -s \
"http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule&smartresult=ugc&sessionFrom=dict.top" \
-d \
"type=AUTO& i=$1&doctype=json&xmlVersion=1.4&keyfrom=fanyi.web&ue=UTF-8&typoResult=true&flag=false" \
| sed -E -n 's/.*tgt":"([^"]+)".*/\1/p' ;
return 0;
}
设置如下:
linux用户:
1.添加此脚本到~/.bashrc的末尾
2.source ~/.bashrc
Mac osX用户:
1.添加此脚本到~/.bash_profile的末尾,没有就新建
2.source ~/.bash_profile
使用:
Shell代码
$ ts hello
你好
$ ts "how are you?"
你好吗?
也可以翻译中文。
原文地址
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。