Socket
Book a DemoInstallSign in
Socket

gtrans

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gtrans

google translate api library

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

Flattr this git repo Build Status

gtrans

Installation

npm install gtrans

Duh.

Translation Example

var gtrans = require('gtrans');

var t = new gtrans("apikey");

var opts = {
  text: "Hello, world!",
  source: "en", // This is optional. Language can be auto-detected.
  target: "de"
};

t.translate(opts).then(console.log);

Console output:

[ { translatedText: 'Hallo Welt!' } ]

Language Detection Example

var gtrans = require('gtrans');

var t = new gtrans("apikey");

t.detect("Hello, world!").then(console.log);

Console output:

[ [ { language: 'en', isReliable: false, confidence: 0.7100697 } ] ]

gtrans can also detect multiple strings, like this.

t.detect("one", "two")

Running tests

  • npm install
  • Rename test/key.template.json to test/key.json and add your Google Translate API key
  • npm test

Keywords

google

FAQs

Package last updated on 14 Aug 2016

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