google-translate-api-nodejs-client
Advanced tools
Comparing version 1.5.1 to 1.5.2
@@ -1,22 +0,105 @@ | ||
var request = require('request'), | ||
Logger = require('logb').getLogger(module.filename); | ||
var API_KEY = process.env.GOOGLE_TRANSLATE_API_KEY, | ||
URL = 'https://www.googleapis.com/language/translate/v2/languages?key=' + API_KEY; | ||
request(URL, function(err, httpResponse, body) { | ||
console.log('Avaiable languages are:'); | ||
body = JSON.parse(body); | ||
console.log(body.data.languages.map(function(e) { | ||
return e.language | ||
}).join('\n')); | ||
console.log(); | ||
console.log('---> Check also', 'https://cloud.google.com/translate/v2/using_rest#language-params', 'to get all language abbreviations'); | ||
console.log(); | ||
console.log(); | ||
console.log(); | ||
}); | ||
module.exports = [ | ||
'af', | ||
'am', | ||
'ar', | ||
'az', | ||
'be', | ||
'bg', | ||
'bn', | ||
'bs', | ||
'ca', | ||
'ceb', | ||
'co', | ||
'cs', | ||
'cy', | ||
'da', | ||
'de', | ||
'el', | ||
'en', | ||
'eo', | ||
'es', | ||
'et', | ||
'eu', | ||
'fa', | ||
'fi', | ||
'fr', | ||
'fy', | ||
'ga', | ||
'gd', | ||
'gl', | ||
'gu', | ||
'ha', | ||
'haw', | ||
'hi', | ||
'hmn', | ||
'hr', | ||
'ht', | ||
'hu', | ||
'hy', | ||
'id', | ||
'ig', | ||
'is', | ||
'it', | ||
'iw', | ||
'ja', | ||
'jw', | ||
'ka', | ||
'kk', | ||
'km', | ||
'kn', | ||
'ko', | ||
'ku', | ||
'ky', | ||
'la', | ||
'lb', | ||
'lo', | ||
'lt', | ||
'lv', | ||
'mg', | ||
'mi', | ||
'mk', | ||
'ml', | ||
'mn', | ||
'mr', | ||
'ms', | ||
'mt', | ||
'my', | ||
'ne', | ||
'nl', | ||
'no', | ||
'ny', | ||
'pa', | ||
'pl', | ||
'ps', | ||
'pt', | ||
'ro', | ||
'ru', | ||
'sd', | ||
'si', | ||
'sk', | ||
'sl', | ||
'sm', | ||
'sn', | ||
'so', | ||
'sq', | ||
'sr', | ||
'st', | ||
'su', | ||
'sv', | ||
'sw', | ||
'ta', | ||
'te', | ||
'tg', | ||
'th', | ||
'tl', | ||
'tr', | ||
'uk', | ||
'ur', | ||
'uz', | ||
'vi', | ||
'xh', | ||
'yi', | ||
'yo', | ||
'zh', | ||
'zh-TW', | ||
'zu',] |
@@ -1,3 +0,2 @@ | ||
/* jshint node:true */ | ||
'use strict'; | ||
const availableLanguages = require('./availableLanguages'); | ||
@@ -19,2 +18,3 @@ | ||
this.limiter = new RateLimiter(1, 'second'); | ||
this.availableLanguages = availableLanguages; | ||
@@ -33,24 +33,4 @@ | ||
// return new Promise((resolve, reject) => { | ||
return this.availableLanguages; | ||
if (this.availableLanguages) { | ||
return cb(null, this.availableLanguages); | ||
} | ||
const URL = 'https://www.googleapis.com/language/translate/v2/languages?key=' + this.API_KEY; | ||
request(URL, (err, httpResponse, body) => { | ||
if (err) { | ||
return cb(err); | ||
} | ||
if (httpResponse.statusCode !== 200) { | ||
return cb(new Error('Status Code of the response is ' + httpResponse.statusCode)); | ||
} | ||
// console.log('Avaiable languages are:'); | ||
body = JSON.parse(body); | ||
const languages = body.data.languages.map(function(e) { | ||
return e.language | ||
}); | ||
this.availableLanguages = languages; | ||
cb(null, languages); | ||
}); | ||
// }); | ||
@@ -57,0 +37,0 @@ }; |
{ | ||
"name": "google-translate-api-nodejs-client", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "google-translate-api-nodejs-client.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13445
8
398