Default number formatting functions in the style of ICU's simpleArg syntax implemented using the Intl object defined by ECMA-402.
Note: Intl is not defined in default Node until 0.11.15 / 0.12.0, so earlier versions require a polyfill. Therefore MessageFormat.withIntlSupport needs to be true for these functions to be available for inclusion in the output.
Properties:
Name | Type | Description |
---|---|---|
number |
function | Represent a number as an integer, percent or currency value |
date |
function | Represent a date as a full/long/default/short string |
time |
function | Represent a time as a full/long/default/short string |
- Source:
- See:
Examples
> var MessageFormat = require('messageformat');
> var mf = (new MessageFormat('en')).setIntlSupport(true);
> mf.currency = 'EUR';
> var mfunc = mf.compile("The total is {V,number,currency}.");
> mfunc({V:5.5})
"The total is €5.50."
> var MessageFormat = require('messageformat');
> var mf = new MessageFormat('en', null, {number: MessageFormat.number});
> mf.currency = 'EUR';
> var mfunc = mf.compile("The total is {V,number,currency}.");
> mfunc({V:5.5})
"The total is €5.50."