google-translate-api-nodejs-client
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -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; | ||
} |
{ | ||
"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(); | ||
}); | ||
}); | ||
}) |
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
6794
125
4