Git Product home page Git Product logo

node_google_translate's Introduction

Translate Google

free google translate

Change Log

Features

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

Install

npm install --save translate-google

Usage

Perfect support object:

const translate = require('translate-google')
const tranObj = {
  a: 1,
  b: '1',
  c: "How are you?\nI'm nice.",
  d: [true, 'true', 'hi', { a: 'hello', b: ['world']}],
}

translate(tranObj, {to: 'zh-cn', except:['a']}).then(res => {
    console.log(res)
}).catch(err => {
    console.error(err)
})

// => { a: 1, b: '1', c: "你好吗?\n我很好。", d: [true, 'true', '嗨', { a: 'hello', b: ['世界']}] }

From automatic language detection to English:

const translate = require('translate-google')

translate('I speak Chinese', {to: 'zh-cn'}).then(res => {
    console.log(res)
}).catch(err => {
    console.error(err)
})

From English to Dutch with a typo:

translate('I speak Chinese!', {from: 'en', to: 'zh-cn'}).then(res => {
    console.log(res)
}).catch(err => {
    console.error(err)
})

translate for array or object:

translate({a: 'I speak Chinese!', b: ['hello', 'world']}, {from: 'en', to: 'zh-cn'}).then(res => {
    console.log(res)
}).catch(err => {
    console.error(err)
})

API

translate(text, options)

text

Type: string, object, array 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.

except

Type: array Default:[] Attributes in excluded objects do not participate in translation

Returns an object:

  • text (string, object, array) – The translated text.
translate(['I speak Chinese\nHello world', 'hello'], {from: 'en', to: 'nl'}).then(res => {
    console.log(res);
    //=> ["我说中文\n你好世界","你好"]
}).catch(err => {
    console.error(err);
});

License

MIT © Shikar

node_google_translate's People

Contributors

shikar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

node_google_translate's Issues

Data used?

Do you have any idea as to how much this uses data?
And, is it healthy if I use that with discord's onMessage call?

BAD_NETWORK

I got this issue when i put my bot on Heroku.
Did you fix it ?

found 3 vulnerabilities ( 2 high, 1 critical)

High Sandbox Breakout / Arbitrary Code Execution

Package safe-eval

Patched in No patch available

Dependency of translation-google

Path translation-google > safe-eval

More info https://npmjs.com/advisories/1033

Critical Sandbox Breakout / Arbitrary Code Execution

Package safe-eval

Patched in No patch available

Dependency of translation-google

Path translation-google > safe-eval

More info https://npmjs.com/advisories/1322

High Prototype Pollution

Package dot-prop

Patched in >=5.1.1

Dependency of translation-google

Path translation-google > configstore > dot-prop

More info https://npmjs.com/advisories/1213

ERROR

Google took action and this system no longer works

Error 403 in docker

On my windows PC it works fine but when I deploy my server in a docker on linux I am getting the following error:

image

I have looked at the line where it is giving the error of the library, the question is that it checks that the .code is != undefined so that it is a BAD_REQUEST error but it is not entering here having a 403

Is anything known about this?

403 Bad network

I think there is no solution for this I only can delete it.......
Because no answer for fix this problem

Readme Suggestion

Under translate(text, options), the following changes can make the reading smoother.

text
Type: string, object, array The text to be translated

options
Type: object

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

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

except
Type: array
Default:[]
Description: Attributes in excluded objects do not participate in translation

(This is my assignment to modify the public technical writing, thank you for taking your time.)

Found CRITICAL vulnerabilities.

Version: 1.4.3

Hello,
This NPM package has found CRITICAL vulnerabilities.

Logs:

High            Sandbox Breakout / Arbitrary Code Execution                   

  Package         safe-eval                                                     

  Patched in      No patch available                                            

  Dependency of   translate-google                                              

  Path            translate-google > safe-eval                                  

  More info       https://npmjs.com/advisories/1033                             


  Critical        Sandbox Breakout / Arbitrary Code Execution                   

  Package         safe-eval                                                     

  Patched in      No patch available                                            

  Dependency of   translate-google                                              

  Path            translate-google > safe-eval                                  

  More info       https://npmjs.com/advisories/1322                             

found 2 vulnerabilities (1 high, 1 critical) in 248 scanned packages
  2 vulnerabilities require manual review. See the full report for details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.