Commits

Jun Omae committed 9800c7b

0.12.4dev: fixed `babel.format` doesn't work on IE6/7 and format with repeated percent signs works wrong

Closes #10697.

Comments (0)

Files changed (1)

trac/htdocs/js/babel.js

 var babel = new function() {
 
   var defaultPluralExpr = function(n) { return n == 1 ? 0 : 1; };
-  var formatRegex = /%?%(?:\(([^\)]+)\))?([disr])/g;
+  var formatRegex = /%(?:(?:\(([^\)]+)\))?([disr])|%)/g;
 
   /**
    * A translations object implementing the gettext interface
         arg[i - 1] = arguments[i];
     }
     return string.replace(formatRegex, function(all, name, type) {
-      if (all[0] == all[1]) return all.substring(1);
+      if (all == '%%') return '%';
       var value = arg[name || idx++];
       return (type == 'i' || type == 'd') ? +value : value; 
     });