Socket
Socket
Sign inDemoInstall

google-translate-api

Package Overview
Dependencies
30
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    google-translate-api

A free and unlimited API for Google Translate


Version published
Weekly downloads
2.7K
decreased by-21.42%
Maintainers
1
Install size
306 kB
Created
Weekly downloads
 

Readme

Source

google-translate-api Build Status XO code style Coverage Status codecov

A free and unlimited API for Google Translate :dollar::no_entry_sign:

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 google-translate-api

Usage

const translate = require('google-translate-api');

translate('Ik spreek Engels', {from: 'auto', to: 'en'}).then(res => {
    console.log(res.text);
    //=> I speak English

    console.log(res.from.language.iso);
    //=> nl
});

API

translate(text, options)

Returns an object with:

  • text (string) – The translated text.
  • from (object)
    • language (object)
      • didYouMean (boolean) - Will be true if the API suggest a correction in the source language
      • iso (string) - The code of the language that the API has recognized in the text
    • text (object)
      • autoCorrected (boolean) – Will be true if the API has auto corrected the text
      • value (string) – The auto corrected text or the text with suggested corrections
      • didYouMean (booelan) – Will be true if the API has suggested corrections to the text

Note that res.from.text will only be returned if from.text.autoCorrected or from.text.didYouMean equals to true. In this case, it will have the corrections delimited with brackets ([ ]):

translate('I spea Dutch').then(res => {
    console.log(res.from.text.value);
    //=> I [speak] Dutch
});

Otherwise, it will be an empty string ('').

text

Type: string

The text to be translated

options

Type: object

from

Type: string Default: 'auto'

The text language. Must be 'auto', '' (same effect of 'auto') or one of the codes contained in languages.js.

to

Type: string

The language in which the text should be translated. Must be one of the codes contained in languages.js.

License

MIT © Matheus Fernandes

Keywords

FAQs

Last updated on 18 May 2016

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc