From ce1f382dd0df080217ce44cc4a59204bd34fd4a0 Mon Sep 17 00:00:00 2001 From: Adam Hoyle Date: Thu, 6 Apr 2017 17:23:18 +0100 Subject: [PATCH 1/2] fix(yandex): fix error with deeply nested objects (e.g. objects which only contain objects, and no strings) --- lib/service/yandex.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/service/yandex.js b/lib/service/yandex.js index 6760b4c..80fde99 100644 --- a/lib/service/yandex.js +++ b/lib/service/yandex.js @@ -16,6 +16,11 @@ function translateString(language, key, destObj) { return new Promise(function (resolve, reject) { var valuesStr = valuesArray.join(hashSimple); + if (valuesStr === ''){ + // there is nothing to translate, so don't ask Yandex (Yandex will respond with an error) + resolve(destObj); + return; + } translateService.translate(valuesStr, {to: language}, function (err, res) { if (err || !res) { reject('Yandex translation service failed', err); From 07bff10a342d29907d24e0aab46d0dfa24ed7420 Mon Sep 17 00:00:00 2001 From: Adam Hoyle Date: Thu, 6 Apr 2017 17:34:58 +0100 Subject: [PATCH 2/2] fix(yandex): fix error with deeply nested objects (e.g. objects which only contain objects, and no strings) also made linter happy ;-) --- lib/service/yandex.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/service/yandex.js b/lib/service/yandex.js index 80fde99..c37c0e7 100644 --- a/lib/service/yandex.js +++ b/lib/service/yandex.js @@ -16,7 +16,7 @@ function translateString(language, key, destObj) { return new Promise(function (resolve, reject) { var valuesStr = valuesArray.join(hashSimple); - if (valuesStr === ''){ + if (valuesStr === '') { // there is nothing to translate, so don't ask Yandex (Yandex will respond with an error) resolve(destObj); return;