function text strings if typeof strings object return text replace d-_

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
function L(text, strings) {
if ((typeof strings == "object")) {
return text.replace(/\{([\w\d-_]+)\}/gim, function (m, s) {
return strings[s] !== undefined ? strings[s] : m;
});
} else if (arguments.length > 1) {
var str = arguments;
return text.replace(/\{(\d+)\}/gim, function (m, s) {
return s < str.length - 1 ? str[+s + 1] : m;
});
}
return text;
}