Modify ↓
#10697 closed defect (fixed)
babel.format doesn't work on IE 6 and 7
Reported by: | Jun Omae | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Milestone: | 0.12.4 |
Component: | i18n | Version: | 0.12 |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
babel.format doesn't work on IE 6 and 7. And babel.format('%%%s', ...)
, repeated percent signs, also is wrong on all browsers.
Expression | IE 6 and 7 | Others | Expected |
---|---|---|---|
babel.format('blah %s', 'arg1'); | blah s | blah arg1 | blah arg1
|
babel.format('blah %(first)s', {first: 'arg1'}); | blah (first)s | blah arg1 | blah arg1
|
babel.format('%%%(arg)s', {arg: 'blah'}); | %%(arg)s | %%(arg)s | %blah
|
I will apply the following patch later.
-
babel.js
36 36 var babel = new function() { 37 37 38 38 var defaultPluralExpr = function(n) { return n == 1 ? 0 : 1; }; 39 var formatRegex = /% ?%(?:\(([^\)]+)\))?([disr])/g;39 var formatRegex = /%(?:(?:\(([^\)]+)\))?([disr])|%)/g; 40 40 41 41 /** 42 42 * A translations object implementing the gettext interface … … 151 151 arg[i - 1] = arguments[i]; 152 152 } 153 153 return string.replace(formatRegex, function(all, name, type) { 154 if (all [0] == all[1]) return all.substring(1);154 if (all == '%%') return '%'; 155 155 var value = arg[name || idx++]; 156 156 return (type == 'i' || type == 'd') ? +value : value; 157 157 });
Attachments (0)
Change History (2)
comment:1 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 by , 13 years ago
Owner: | set to |
---|
Note:
See TracTickets
for help on using tickets.
Committed in [11047] and [11048].