0.0.1 • Published 6 years ago

sogou-translate v0.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

Sogou Translate

使用搜狗深智引擎翻译文本。 Translate with Sogou DeepI API.

Install

npm i sogou-translate

Example

使用前请先到搜狗深智引擎申请一个机器翻译的账户,获取到 PID 和 Key,申请地址:http://deepi.sogou.com/contact/fanyi

分别替换掉下面例子中的 your_pidyour_key 即可运行。

接口中的 fromto 字段可选值参考:http://deepi.sogou.com/docs/fanyiDoc#lan

const SogouTranslate = require('sogou-tranlsate');
const sogouTranslate = new SogouTranslate('your_pid', 'your_key');

// 翻译“hello”,从英文翻译成中文
sogouTranslate.translate('hello', 'en', 'zh-CHS') 
.then(result => {
    console.log(result); // 你好
})