New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

translate-baidu

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

translate-baidu

A free and unlimited for Baidu Translate, Multi-translation support object input

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

Translate Baidu

free baidu translate

Change Log

  • changelog.md

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

Keywords

translate

FAQs

Package last updated on 15 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts