use spread in messages
This commit is contained in:
parent
c5d3f42d8a
commit
ee0ac9f149
@ -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) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user