Edgewall Software
Modify

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#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

     
    3636var babel = new function() {
    3737
    3838  var defaultPluralExpr = function(n) { return n == 1 ? 0 : 1; };
    39   var formatRegex = /%?%(?:\(([^\)]+)\))?([disr])/g;
     39  var formatRegex = /%(?:(?:\(([^\)]+)\))?([disr])|%)/g;
    4040
    4141  /**
    4242   * A translations object implementing the gettext interface
     
    151151        arg[i - 1] = arguments[i];
    152152    }
    153153    return string.replace(formatRegex, function(all, name, type) {
    154       if (all[0] == all[1]) return all.substring(1);
     154      if (all == '%%') return '%';
    155155      var value = arg[name || idx++];
    156156      return (type == 'i' || type == 'd') ? +value : value;
    157157    });

Attachments (0)

Change History (2)

comment:1 by Jun Omae, 13 years ago

Resolution: fixed
Status: newclosed

Committed in [11047] and [11048].

comment:2 by Jun Omae, 13 years ago

Owner: set to Jun Omae

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.