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

asksuite-translate-json-object

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asksuite-translate-json-object - npm Package Compare versions

Comparing version 0.0.5-development to 0.0.6-development

44

lib/service/google.js

@@ -6,2 +6,3 @@ var translateService;

var client;
var map

@@ -11,23 +12,46 @@

client = request.createClient(url.url);
map = new Map();
}
// eslint-disable-next-line max-params
function translateObject(language, key, destObj, keysArray, valuesArray) {
return new Promise(function (resolve, reject) {
client.post('translate/' + language, valuesArray)
.then(function (result) {
if (map.get(JSON.stringify(valuesArray))){
var res = result.body;
console.log("entrei aqui no repedido")
var res = map.get(JSON.stringify(valuesArray))
for (var i = 0; i < keysArray.length; i++) {
destObj[key][keysArray[i]] = res[i];
}
for (var i = 0; i < keysArray.length; i++) {
destObj[key][keysArray[i]] = res[i];
}
resolve(destObj);
resolve(destObj);
}).catch(function (err) {
reject(err);
})
}else{
client.post('translate/' + language, valuesArray)
.then(function (result) {
var res = result.body;
map.set(JSON.stringify(valuesArray), res)
for (var i = 0; i < keysArray.length; i++) {
destObj[key][keysArray[i]] = res[i];
}
resolve(destObj);
}).catch(function (err) {
console.log("deu erro", err);
reject(err);
})
}
});

@@ -34,0 +58,0 @@

var _ = require('lodash');
var Promise = require('promise');
var Promise = require('bluebird');
var constant = require('./util/constant');

@@ -134,3 +134,3 @@ var isValidLang = require('./util/valid-lang');

if (valuesArray.length !== 0) {
promises.push(translateSrv.object(language, key, dest, keysArray, valuesArray));
promises.push({language: language, key: key, dest: dest, keysArray: keysArray, valuesArray: valuesArray});
}

@@ -145,3 +145,6 @@ }

return new Promise(function (resolve, reject) {
Promise.all(promises).then(function () {
Promise.map(promises, function(promise) {
// Promise.map awaits for returned promises as well.
return translateSrv.object(promise.language, promise.key, promise.dest, promise.keysArray, promise.valuesArray)
}, {concurrency: 12}).then(function(res) {
if (ARRAY_ROOT_TYPE) {

@@ -152,4 +155,12 @@ resolve(destObj.ROOT.arrayType);

}
}).catch(reject);
}).catch(error => {
console.log(error)
console.log("deu erro ao traduri")
})
});
}

@@ -156,0 +167,0 @@

{
"name": "asksuite-translate-json-object",
"version": "0.0.5-development",
"version": "0.0.6-development",
"description": "Translate a JSON object to any language via google or yandex translate API",

@@ -16,2 +16,3 @@ "main": "lib/translate-json-object.js",

"dependencies": {
"bluebird": "^3.5.1",
"google-translate": "2.0.5",

@@ -18,0 +19,0 @@ "lodash": "4.17.3",

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