diff --git a/public/src/modules/translator.js b/public/src/modules/translator.js index a861f8fc39..74d6b867c2 100644 --- a/public/src/modules/translator.js +++ b/public/src/modules/translator.js @@ -541,7 +541,10 @@ } if (!(typeof text === 'string' || text instanceof String) || text === '') { - return cb(''); + if (cb) { + return setTimeout(cb, 0, ''); + } + return ''; } return Translator.create(lang).translate(text).then(function (output) { diff --git a/test/translator.js b/test/translator.js index 43dac6f692..628300166d 100644 --- a/test/translator.js +++ b/test/translator.js @@ -21,6 +21,18 @@ describe('Translator shim', function () { done(); }); }); + + it('should translate empty string properly', function (done) { + shim.translate('', 'en-GB', function (translated) { + assert.strictEqual(translated, ''); + done(); + }); + }); + + it('should translate empty string properly', async function () { + const translated = await shim.translate('', 'en-GB'); + assert.strictEqual(translated, ''); + }); }); });