Edgewall Software

Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#10717 closed enhancement (fixed)

js: make it unnecessary to call babel.format explicitly

Reported by: Christian Boos Owned by: Christian Boos
Priority: normal Milestone: 1.0
Component: i18n Version: 0.13dev
Severity: normal Keywords: babel javascript
Cc: Branch:
Release Notes:

(JavaScript API improvement)

API Changes:

babel.js: it's no longer necessary to call babel.format, one can directly pass formatting parameters to gettext, _ and ngettext (r11068)

Internal Changes:

Description (last modified by Christian Boos)

On the topic of babel.format, any reason why it couldn't be integrated in gettext?

For example, writing:

title: _("Select ticket %(id)s for modification", {id: tId}),

instead of the cumbersome:

title: babel.format(_("Select ticket %(id)s for modification"), {id: tId}),

The change is fully backward compatible.

Now that Jun started to "customize" our babel.js in r11047… Ok, at some point someone should backport this to Babel:source:trunk/contrib/babel.js ;-)

Related branches

Attachments (0)

Change History (4)

comment:1 by Christian Boos, 11 years ago

Description: modified (diff)

comment:2 by Jun Omae, 11 years ago

Nice idea! I just tested and it works fine.

However, ngettext() doesn't format when the string of singular is not in the catalog, 7055b55/jomae.git.

comment:3 by Christian Boos, 11 years ago

API Changes: modified (diff)
Resolution: fixed
Status: newclosed

Thanks for the feedback! I integrated your fix and rebased the result, plus additional whitespace fixes in repos:cboos.git:ticket10717/babeljs-format-in-gettext.2.

Then committed this as r11068.

comment:4 by Christian Boos, 10 years ago

Release Notes: modified (diff)

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos 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.