function ts(text, params) {
"use strict";
text = CRM.strings[text] || text;
- if (params && typeof(params) === 'object') {
+ if (typeof(params) === 'object') {
for (var i in params) {
- // sprintf emulation: escape % characters in the replacements to avoid conflicts
- text = text.replace(new RegExp('%' + i, 'g'), params[i].replace(/%/g, '%-crmescaped-'));
+ if (typeof(params[i]) === 'string' || typeof(params[i]) === 'number') {
+ // sprintf emulation: escape % characters in the replacements to avoid conflicts
+ text = text.replace(new RegExp('%' + i, 'g'), String(params[i]).replace(/%/g, '%-crmescaped-'));
+ }
}
return text.replace(/%-crmescaped-/g, '%');
}