Skip to content

Commit

Permalink
Use matheuss/google-translate-token
Browse files Browse the repository at this point in the history
  • Loading branch information
matheuss committed Jul 2, 2016
1 parent 8dd93ef commit e134f03
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 143 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var querystring = require('querystring');
var got = require('got');
var tk = require('./tk');
var token = require('google-translate-token');

function translate(text, opts) {
opts = opts || {};
return tk(text).then(function (tk) {
return token.get(text).then(function (token) {
var url = 'https://translate.google.com/translate_a/single';
var data = {
client: 't',
Expand All @@ -18,9 +18,9 @@ function translate(text, opts) {
ssel: 0,
tsel: 0,
kc: 7,
tk: opts.tk || tk,
q: text
};
data[token.name] = token.value;

return url + '?' + querystring.stringify(data);
}).then(function (url) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"homepage": "https://github.com/matheuss/google-translate-api#readme",
"dependencies": {
"configstore": "^2.0.0",
"google-translate-token": "latest",
"got": "^6.3.0"
},
"devDependencies": {
Expand All @@ -47,7 +48,6 @@
"no-eval": 1
},
"ignores": [
"tk.js",
"languages.js"
]
}
Expand Down
8 changes: 0 additions & 8 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ test('translate some misspelled english text to dutch', async t => {
}
});

test('translate some text with an invalid tk', async t => {
try {
await translate('vertaler', {tk: 0});
} catch (err) {
t.is(err.code, 'BAD_REQUEST');
}
});

test.todo('try to translate some text without an internet connection');

test('translate some text and get the raw output alongside', async t => {
Expand Down
131 changes: 0 additions & 131 deletions tk.js

This file was deleted.

0 comments on commit e134f03

Please sign in to comment.