Edgewall Software

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#10717 closed enhancement (fixed)

js: make it unnecessary to call babel.format explicitly — at Version 4

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

Change History (4)

comment:1 by Christian Boos, 12 years ago

Description: modified (diff)

comment:2 by Jun Omae, 12 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, 12 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, 12 years ago

Release Notes: modified (diff)
Note: See TracTickets for help on using tickets.