translate-baidu

1.0.1 • Public • Published

Translate Baidu

free baidu translate

Change Log

Features

  • Auto language detection
  • Spelling correction
  • Language correction
  • Fast and reliable – it uses the same servers that fanyi.baidu.com uses

Install

npm install --save translate-baidu

Usage

const translate = require('translate-baidu')
 
translate('hello').then(res => {
    console.log(res)
}).catch(err => {
    console.error(err)
})
 
// => { from: "en", to: "zh", dst: "你好", src: "hello" }

API

translate(text, options)

text

Type: string The text to be translated

options

Type: object

from

Type: string Default: auto The text language. Must be auto or one of the codes/names (not case sensitive) contained in languages.js

to

Type: string Default: en The language in which the text should be translated. Must be one of the codes/names (not case sensitive) contained in languages.js.

full

Type: Boolean Default: false Return to the Full Baidu translation result object

Returns an object:

  • text (string) – The translated text.
translate('Hello world', {from: 'en', to: 'nl'}).then(res => {
    console.log(res);
    //=> { from: "en", to: "zh", dst: "你好,世界", src:"Hello world"}
}).catch(err => {
    console.error(err);
});

License

MIT © Shikar

Package Sidebar

Install

npm i translate-baidu

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

12.4 kB

Total Files

10

Last publish

Collaborators

  • shikar