A proposal to add String.prototype.format

Shanjian Li shanjian at google.com
Tue Mar 8 16:21:09 PST 2011

EcmaScript lacks a method to format strings in a flexible and controllable
manner. Most EcmaScript strings are constructed by concatenating a series of
substrings. Such practice really hurts code readability. Especially for
localization, it is almost impossible to translate the string when it is
split into multiple pieces. This problem has been identified long before.
Brendan Eich proposed something in 2006 for ECMA 3
Mike Samuel’s quasis<http://wiki.ecmascript.org/doku.php?id=strawman:quasis>and
Douglas Crockford’s
proposed a solution as well. This proposal references those proposals,
and borrows many ideas introduced by Python (
http://www.python.org/dev/peps/pep-3101/). This proposal also applies
lessons learned in Localization (l10n) and Internationalization (i18n)
practice, both in Javascript and other languages.

Please kindly review the proposal and let me know your feedback.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110308/41c4b852/attachment.html>

More information about the es-discuss mailing list