use spread in messages

This commit is contained in:
Sebastian McKenzie 2015-03-09 16:54:30 +11:00
parent c5d3f42d8a
commit ee0ac9f149

View File

@ -24,14 +24,10 @@ export var messages = {
unsupportedOutputType: "Unsupported output type $1" unsupportedOutputType: "Unsupported output type $1"
}; };
export function get(key) { export function get(key, ...args) {
var msg = messages[key]; var msg = messages[key];
if (!msg) throw new ReferenceError(`Unknown message ${JSON.stringify(key)}`); if (!msg) throw new ReferenceError(`Unknown message ${JSON.stringify(key)}`);
var args = [];
for (var i = 1; i < arguments.length; i++) {
args.push(arguments[i]);
}
args = parseArgs(args); args = parseArgs(args);
return msg.replace(/\$(\d+)/g, function (str, i) { return msg.replace(/\$(\d+)/g, function (str, i) {