Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

google-translate-api-nodejs-client

Package Overview
Dependencies
Maintainers
2
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-translate-api-nodejs-client - npm Package Compare versions

Comparing version 1.5.1 to 1.5.2

getAvailableLanguages.js

127

availableLanguages.js

@@ -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',]

26

google-translate-api-nodejs-client.js

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc