function t(s,d){
for(var p in d) s=s.replace(new RegExp('{'+p+'}','g'), typeof d[p][1]=='f' ? d[p]() : d[p]);
return s;
}
Uso
t("Hello {who}! It's {time} ms since epoch.", { who: "JavaScript", time: Date.now });
// "Hello JavaScript! It's 1299680443046 ms since epoch."