diff options
Diffstat (limited to 'deps/npm/node_modules/cacache/node_modules/y18n/index.js')
-rw-r--r-- | deps/npm/node_modules/cacache/node_modules/y18n/index.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/deps/npm/node_modules/cacache/node_modules/y18n/index.js b/deps/npm/node_modules/cacache/node_modules/y18n/index.js index 91b159e342..d720681628 100644 --- a/deps/npm/node_modules/cacache/node_modules/y18n/index.js +++ b/deps/npm/node_modules/cacache/node_modules/y18n/index.js @@ -16,6 +16,9 @@ function Y18N (opts) { } Y18N.prototype.__ = function () { + if (typeof arguments[0] !== 'string') { + return this._taggedLiteral.apply(this, arguments) + } var args = Array.prototype.slice.call(arguments) var str = args.shift() var cb = function () {} // start with noop. @@ -40,6 +43,19 @@ Y18N.prototype.__ = function () { return util.format.apply(util, [this.cache[this.locale][str] || str].concat(args)) } +Y18N.prototype._taggedLiteral = function (parts) { + var args = arguments + var str = '' + parts.forEach(function (part, i) { + var arg = args[i + 1] + str += part + if (typeof arg !== 'undefined') { + str += '%s' + } + }) + return this.__.apply(null, [str].concat([].slice.call(arguments, 1))) +} + Y18N.prototype._enqueueWrite = function (work) { this.writeQueue.push(work) if (this.writeQueue.length === 1) this._processWriteQueue() |