All Projects → djyde → node-baidu-translate

djyde / node-baidu-translate

Licence: other
Baidu translate SDK for Node.js

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

node-baidu-translate

npm CircleCI npm npm

http://api.fanyi.baidu.com/api/trans/product/apidoc

Install

npm install --save-dev node-baidu-translate

Quick Start

import BaiduTranslate from 'node-baidu-translate'

const bdt = new BaiduTranslate(APPID, SECRET_KEY)

bdt.translate('apple', 'en').then(res => {
  console.log(res)
  // { from: 'en',
  //   to: 'zh',
  //   trans_result: [ { src: 'apple', dst: '苹果' } ] 
  // }
})

API

constructor(appId: string, secretKey: string, endPoint?: string): baiduTranslateInstance

  • appId

  • secretKey

  • endPoint

    API 请求 endpoint, 一般不需要填

baiduTranslateInstance.translate(query: string, to: string, from?: string = 'auto'): Promise

License

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].