Bug 1406311 - sprintfjs: stop using spread arguments when calling sprintf()
MozReview-Commit-ID: 5t2LRYWtuei
--- a/devtools/shared/l10n.js
+++ b/devtools/shared/l10n.js
@@ -113,18 +113,18 @@ LocalizationHelper.prototype = {
/**
* L10N shortcut function.
*
* @param string name
* @param array args
* @return string
*/
- getFormatStr: function (name, ...args) {
- return sprintf(this.getStr(name), ...args);
+ getFormatStr: function (name) {
+ return sprintf(this.getStr(name), arguments);
},
/**
* L10N shortcut function for numeric arguments that need to be formatted.
* All numeric arguments will be fixed to 2 decimals and given a localized
* decimal separator. Other arguments will be left alone.
*
* @param string name
--- a/devtools/shared/sprintfjs/sprintf.js
+++ b/devtools/shared/sprintfjs/sprintf.js
@@ -46,27 +46,27 @@
modulo: /^\x25{2}/,
placeholder: /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijosStTuvxX])/,
key: /^([a-z_][a-z_\d]*)/i,
key_access: /^\.([a-z_][a-z_\d]*)/i,
index_access: /^\[(\d+)\]/,
sign: /^[\+\-]/
}
- function sprintf() {
- var key = arguments[0], cache = sprintf.cache
+ function sprintf(key, args) {
+ var cache = sprintf.cache
if (!(cache[key] && cache.hasOwnProperty(key))) {
cache[key] = sprintf.parse(key)
}
- return sprintf.format.call(null, cache[key], arguments)
+ return sprintf.format.call(null, cache[key], key, args)
}
- sprintf.format = function(parse_tree, argv) {
+ sprintf.format = function(parse_tree, key, argv) {
if (parse_tree === SIMPLE_PATTERN) {
- return argv[0].replace("%S", argv[1]);
+ return key.replace("%S", argv[1]);
}
var cursor = 1, tree_length = parse_tree.length, arg, output = [], i, k, match, pad, pad_character, pad_length, is_positive = true, sign = ''
for (i = 0; i < tree_length; i++) {
// parse tree contains either substrings or match results (array)
if (typeof parse_tree[i] === 'string') {
output[output.length] = parse_tree[i]
} else {