Permalink
Browse files

Update translate.coffee

  • Loading branch information...
1 parent f92fe11 commit 4c94dbf36507b338db470fb847e925d66628225a @xinyu198736 committed Feb 25, 2016
Showing with 6 additions and 6 deletions.
  1. +6 −6 lib/translate.coffee
View
@@ -4,11 +4,11 @@ en_func = (text,callback)->
request.get "http://openapi.baidu.com/public/2.0/bmt/translate?client_id=HtiSPl1lCtzy0IBuWhuh2VHw&from=zh&to=en&q="+text,(e,r,body)->
console.log body
en = null
- try
- result = JSON.parse body
- en = result.trans_result[0].dst
- catch e
- en = pinyin(text,{heteronym: false,style: pinyin.STYLE_NORMAL}).join("")
+ #try
+ #result = JSON.parse body
+ #en = result.trans_result[0].dst
+ #catch e
+ en = pinyin(text,{heteronym: false,style: pinyin.STYLE_NORMAL}).join("")
callback en.replace(/[^a-zA-Z0-9 ]/g,"").replace( /\s+?/g,"-")
-module.exports = en_func
+module.exports = en_func

0 comments on commit 4c94dbf

Please sign in to comment.