fix: optional params

isekai-main
Barış Soner Uşaklı 3 years ago
parent e841d59a67
commit e9a86cb912

@ -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;
},
/**

Loading…
Cancel
Save