From 8feef0dc42780916fa65cfe0bbe006ab55a6896b Mon Sep 17 00:00:00 2001 From: Patryk Wychowaniec Date: Thu, 13 Aug 2020 14:33:24 +0200 Subject: [PATCH] #1 create entry in my memory translation service --- src/translate/MyMemoryTranslateService.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/translate/MyMemoryTranslateService.js b/src/translate/MyMemoryTranslateService.js index 607d2dc..e9e8fe6 100644 --- a/src/translate/MyMemoryTranslateService.js +++ b/src/translate/MyMemoryTranslateService.js @@ -1,6 +1,7 @@ const fetch = require('node-fetch'); const TranslateService = require('./TranslateService'); +const dictionaryService = require('../dictionaryService'); const API = 'https://api.mymemory.translated.net/get'; @@ -13,7 +14,11 @@ class MyMemoryTranslateService extends TranslateService { fetch(URL) .then(data => data.json()) - .then(data => resolve(data.responseData.translatedText)) + .then(data => { + const translatedText = data.responseData.translatedText; + this.log.addEntry(key, to, translatedText); + resolve(dictionaryService.createEntry(key, translatedText)); + }) .catch(err => reject(err)); }); }