asksuite-translate-json-object
Advanced tools
Comparing version 0.0.2-development to 0.0.3-development
@@ -27,5 +27,10 @@ var _ = require('lodash'); | ||
function init(options) { | ||
setting = options || {}; | ||
if (!setting.googleApiKey && !setting.yandexApiKey) { | ||
if (!setting.googleApiKey && !setting.yandexApiKey && !setting.msKey) { | ||
console.warn(constant.ERROR.MISSING_TOKEN); | ||
@@ -36,5 +41,8 @@ return false; | ||
translateSrv = require('./service/yandex.js'); | ||
} else { | ||
} else if (setting.googleApiKey) { | ||
serviceType = constant.GOOGLE_NAME; | ||
translateSrv = require('./service/google.js'); | ||
} else if (setting.msKey) { | ||
serviceType = constant.MS_NAME; | ||
translateSrv = require('./service/microsoft.js'); | ||
} | ||
@@ -55,3 +63,3 @@ | ||
function translate(srcObj, language, attributesToNotTranslate) { | ||
if (!setting.googleApiKey && !setting.yandexApiKey) { | ||
if (!setting.googleApiKey && !setting.yandexApiKey && !setting.msKey) { | ||
return Promise.reject(constant.ERROR.MISSING_TOKEN); | ||
@@ -58,0 +66,0 @@ } |
module.exports = { | ||
GOOGLE_NAME: 'Google', | ||
YANDEX_NAME: 'Yandex', | ||
MS_NAME: 'Microsoft', | ||
ERROR: { | ||
@@ -5,0 +6,0 @@ MISSING_TOKEN: 'Please provide a option.googleApiKey, or option.yandexApiKey (token key) via invoking the [init] method' |
@@ -12,2 +12,4 @@ var constant = require('./constant'); | ||
return yandex.indexOf(lang) !== -1; | ||
case constant.MS_NAME: | ||
return google.indexOf(lang) !== -1; | ||
default: | ||
@@ -14,0 +16,0 @@ return false; |
{ | ||
"name": "asksuite-translate-json-object", | ||
"version": "0.0.2-development", | ||
"version": "0.0.3-development", | ||
"description": "Translate a JSON object to any language via google or yandex translate API", | ||
@@ -18,2 +18,3 @@ "main": "lib/translate-json-object.js", | ||
"lodash": "4.17.3", | ||
"mstranslator": "^3.0.0", | ||
"promise": "7.1.1", | ||
@@ -20,0 +21,0 @@ "yandex-translate": "2.1.1" |
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
27517
21
570
5
+ Addedmstranslator@^3.0.0
+ Addedmstranslator@3.0.0(transitive)