archives

« Bugzilla Issues Index

#763 — Message formatting


Write a strawman for message formatting - plural and gender support, date, number formatting within a message.

Our proposal should offer support for plural and gender formatting that is compatible with Template Strings.

An example functionality:

Anne invited you and 5 other people to her party.

"5 people", and "her" are language dependent.


Looking at comments from Nicholas (http://www.nczonline.net/blog/2012/08/01/a-critical-review-of-ecmascript-6-quasi-literals/) string templates are hard to use for string reuse (early binding of parameters) and localization (again early binding).

We could define a new tag - plural - to deal with plural messages, but I don't see a nice way in string template mechanism to specify parameters:

1. Locale (it could be global)
2. Plural number

All parameters in the tagged string get pre-evaled and passed in as a string to a function. So we could say that fist two placeholders are locale and plural num, but that seems hacky to me:

plural '${locale}${plural_count}The actual plural string with rules...'.

function plural() {
var locale = arguments[0];
var pluralCount = arguments[1];
// the rest of the logic for formatting.
}

The same applies to gender formatting.


TC 39 suggested looping in Alex Sexton, who has been working on message formatting and may have input.


At the 2012-12-14 internationalization meeting, Nebojša was asked to write a
strawman.