From e9a86cb912f9fb71916acbd91503d84221837a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 8 Mar 2022 14:44:53 -0500 Subject: [PATCH] fix: optional params --- public/src/modules/translator.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/public/src/modules/translator.js b/public/src/modules/translator.js index 34140971cf..45ebca0a7e 100644 --- a/public/src/modules/translator.js +++ b/public/src/modules/translator.js @@ -605,8 +605,18 @@ warn('Translation failed: ' + err.stack); }); }, - translateKeys: async function (keys, language, cb) { - return await Promise.all(keys.map(key => adaptor.translate(key, language, cb))); + translateKeys: async function (keys, language, callback) { + let cb = callback; + let lang = language; + if (typeof language === 'function') { + cb = language; + lang = null; + } + const translations = await Promise.all(keys.map(key => adaptor.translate(key, lang))); + if (typeof cb === 'function') { + return setTimeout(cb, 0, translations); + } + return translations; }, /**