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

@vitalets/google-translate-api

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vitalets/google-translate-api - npm Package Compare versions

Comparing version 5.1.0 to 7.0.0

14

index.js

@@ -94,7 +94,11 @@ var querystring = require('querystring');

} else {
json[1][0][0][5].forEach(function (obj) {
if (obj[0]) {
result.text += obj[0];
}
});
result.text = json[1][0][0][5]
.map(function (obj) {
return obj[0];
})
.filter(Boolean)
// Google api seems to split text per sentences by <dot><space>
// So we join text back with spaces.
// See: https://github.com/vitalets/google-translate-api/issues/73
.join(' ');
}

@@ -101,0 +105,0 @@ result.pronunciation = json[1][0][0][1];

{
"name": "@vitalets/google-translate-api",
"version": "5.1.0",
"version": "7.0.0",
"description": "A free and unlimited API for Google Translate",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -30,10 +30,20 @@ var test = require('ava');

t.false(res.from.text.autoCorrected);
t.is(res.from.text.value, '');
t.false(res.from.text.didYouMean);
t.is(res.from.text.value, '[translate]');
t.true(res.from.text.didYouMean);
});
test('translate several sentences with spaces (#73)', async t => {
const res = await translate(
'translator, translator. translator! translator? translator,translator.translator!translator?',
{from: 'auto', to: 'nl'}
);
t.is(res.text, 'vertaler, vertaler. vertaler! vertaler? Vertaler, vertaler.translator! Vertaler?');
});
test('test pronunciation', async t => {
const res = await translate('translator', {from: 'auto', to: 'zh-CN'});
t.is(res.pronunciation, 'Yì zhě');
// here can be 2 variants: 'Yì zhě', 'Fānyì'
t.regex(res.pronunciation, /^(Yì zhě)|(Fānyì)$/);
});

@@ -40,0 +50,0 @@

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