gtrans

google translate api library

  • gtrans

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
gtrans
1.1.07 years ago7 years agoMinified + gzip package size for gtrans in KB

Readme

Flattr this git repo Build Status
gtrans

Installation

npm install gtrans Duh.

Translation Example

```js 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: ```js { translatedText: 'Hallo Welt!' } ```

Language Detection Example

```js var gtrans = require('gtrans'); var t = new gtrans("apikey"); t.detect("Hello, world!").then(console.log); ``` Console output: ```js { language: 'en', isReliable: false, confidence: 0.7100697 } ``` gtrans can also detect multiple strings, like this. ```js t.detect("one", "two") ```

Running tests

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