Licence
ISC
Version
1.1.0
Deps
0
Vulns
0
Weekly
0
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.jsontotest/key.jsonand add your Google Translate API key npm test
