diff --git a/public/src/modules/translator.js b/public/src/modules/translator.js index e60385ed79..d975e16e1d 100644 --- a/public/src/modules/translator.js +++ b/public/src/modules/translator.js @@ -395,11 +395,13 @@ /** * Construct a translator pattern + * @param {string} name - Translation name + * @param {...string} arg - Optional argument for the pattern */ Translator.compile = function compile() { - var args = Array.prototype.slice.call(arguments, 0); + var args = Array.prototype.slice.call(arguments, 0); - return '[[' + args.join(', ') + ']]'; + return '[[' + args.join(', ') + ']]'; }; return Translator; diff --git a/test/translator.js b/test/translator.js index 60fb589e0d..a89681adef 100644 --- a/test/translator.js +++ b/test/translator.js @@ -223,4 +223,33 @@ describe('Translator static methods', function () { done(); }); }); + describe('.escape', function () { + it('should escape translation patterns within text', function (done) { + assert.strictEqual( + Translator.escape('some nice text [[global:home]] here'), + 'some nice text \\[\\[global:home\\]\\] here' + ); + done(); + }); + }); + + describe('.unescape', function () { + it('should unescape escaped translation patterns within text', function (done) { + assert.strictEqual( + Translator.unescape('some nice text \\[\\[global:home\\]\\] here'), + 'some nice text [[global:home]] here' + ); + done(); + }); + }); + + describe('.compile', function () { + it('should create a translator pattern from a key and list of arguments', function (done) { + assert.strictEqual( + Translator.compile('amazing:cool', 'awesome', 'great'), + '[[amazing:cool, awesome, great]]' + ); + done(); + }); + }); });