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
1
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.0.3 to 1.0.4

16

google-translate-api-nodejs-client.js

@@ -16,3 +16,3 @@ var request = require('request'),

// throttling
this.limiter = new RateLimiter(100, 'second');
this.limiter = new RateLimiter(1, 'second');

@@ -70,3 +70,3 @@

GoogleTranslateApi.prototype.fromGermanToEnglish = function fromGermanToEnglish(text, cb) {
GoogleTranslateApi.prototype.fromGermanToEnglish = function(text, cb) {

@@ -82,2 +82,14 @@ Logger.info('Translating from German to English...');

return;
}
GoogleTranslateApi.prototype.fromSimplifiedChineseToEnglish = function(text, cb) {
Logger.info('Translating from German to English...');
this.translate({
source: 'zh-CN',
target: 'en',
text: text
}, cb);
return;
}

2

package.json
{
"name": "google-translate-api-nodejs-client",
"version": "1.0.3",
"version": "1.0.4",
"description": "",

@@ -5,0 +5,0 @@ "main": "google-translate-api-nodejs-client.js",

@@ -0,1 +1,2 @@

/* nodejs true */
var expect = require('chai').expect,

@@ -12,3 +13,6 @@ path = require('path');

var germanText,
germanTextEnglishTranslation;
germanTextEnglishTranslation,
chineseText,
chineseTextEnglishTranslation,
client;

@@ -20,2 +24,8 @@ beforeEach(function() {

chineseText = '1小时充电就好了,试了下,不错,我胡子较多那种,剃后很干净,比我以前的braun5000系声音低不少,震动也低不少,冰感也很爽,1099秒的,值得拥有,只是没有旅行盒...没有旅行盒....';
chineseTextEnglishTranslation = '1 hour charge is like, try the next, well, I kind of beard large, very clean after shave, lower than my previous braun5000 system sounds a lot, a lot of vibration is low, the ice being too cool, 1099 seconds and worth having, just do not travel without travel case .... box ...';
client = new GoogleTranslateApiClient({
API_KEY: process.env.GOOGLE_TRANSLATE_API_KEY
});
});

@@ -27,8 +37,5 @@

throw new Error('Please specify the env variable GOOGLE_TRANSLATE_API_KEY');
return;
}
new GoogleTranslateApiClient({
API_KEY: process.env.GOOGLE_TRANSLATE_API_KEY
})
client
.fromGermanToEnglish(germanText, function(err, translation) {

@@ -44,7 +51,25 @@ expect(err).to.be.null;

it('should translate a chinese text to right english text', function(done) {
if (!process.env.GOOGLE_TRANSLATE_API_KEY) {
throw new Error('Please specify the env variable GOOGLE_TRANSLATE_API_KEY');
return;
}
client
.fromSimplifiedChineseToEnglish(chineseText, function(err, translation) {
expect(err).to.be.null;
expect(translation).to.be.not.undefined;
expect(translation).to.be.eql(chineseTextEnglishTranslation);
done();
});
});
})
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