Merge pull request #1172 from totten/master-crmContactField-widget
[civicrm-core.git] / js / Common.js
index 294f76b98b295d97f1c3abc569bcacf59e128062..8f5294ef60db3c13e12c62db59dc18e291cfe68b 100644 (file)
@@ -44,10 +44,12 @@ var cj = jQuery;
 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, '%');
   }