Mercurial > babel > old > babel-test
diff contrib/babel.js @ 363:a03ce004eff1
Added documentation to format method in babel.js
author | aronacher |
---|---|
date | Wed, 18 Jun 2008 12:39:01 +0000 |
parents | 9cd9d787dcb2 |
children | 85e1beadacb0 |
line wrap: on
line diff
--- a/contrib/babel.js +++ b/contrib/babel.js @@ -29,7 +29,7 @@ * * Missing elements in the object are ignored. * - * Typical usage: + * Typical usage:: * * var translations = babel.Translations.load(...).install(); */ @@ -129,6 +129,16 @@ } }; + /** + * A python inspired string formatting function. Supports named and + * positional placeholders and "s", "d" and "i" as type characters + * without any formatting specifications. + * + * Examples:: + * + * babel.format(_('Hello %s'), name) + * babel.format(_('Progress: %(percent)s%%'), {percent: 100}) + */ this.format = function() { var arg, string = arguments[0], idx = 0; if (arguments.length == 1)