messageformat
Intl.MessageFormat / Unicode MessageFormat 2 parser, runtime and polyfill
Last updated 2 years ago by eemeli .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install messageformat 
SYNC missed versions from official npm registry.

This library provides a formatter and other tools for Unicode MessageFormat 2.0 (MF2), the new standard for localization developed by the MessageFormat Working Group.

This includes a formatter that can be used as a polyfill for the proposed ECMA-402 Intl.MessageFormat formatter.

The API provided by this library is current as of the LDML 48.2 (March 2026) version of the Unicode MessageFormat specification.

npm install --save messageformat
import { MessageFormat } from 'messageformat';
import { DraftFunctions } from 'messageformat/functions';

const msg = 'Today is {$today :datetime dateStyle=medium}';
const mf = new MessageFormat('en', msg, { functions: DraftFunctions });

mf.format({ today: new Date('2022-02-02') });
// 'Today is Feb 2, 2022'

The library also provides a number of other tools and utilities for MF2, such as:

  • MF2 data model conversion tools

    import { parseMessage, stringifyMessage } from 'messageformat';
    
  • MF2 data model validation and transformation tools

    import { validate, visit } from 'messageformat';
    
  • Concreate Syntax Tree (CST) tools for MF2

    import { parseCST, messageFromCST, stringifyCST } from 'messageformat/cst';
    
  • Utilities for building custom function handlers for MF2

    import {
      DraftFunctions,
      asPositiveInteger,
      asString
    } from 'messageformat/functions';
    

In addition to supporting MF2 syntax, compilers and formatting function runtimes are also provided for ICU MessageFormat and Fluent messages:

For more information on the types and functions provided by this package, see the documentation site.

[!IMPORTANT] The v4 release of the messageformat package has an entirely different API compared to its earlier major releases, which were built on top of ICU MessageFormat, aka "MF1". For that, please see @messageformat/core instead.

Current Tags

  • 4.1.0                                ...           latest (2 months ago)

59 Versions

  • 4.1.0                                ...           2 months ago
  • 4.0.0                                ...           a year ago
  • 4.0.0-13                                ...           a year ago
  • 4.0.0-12                                ...           2 years ago
  • 4.0.0-11                                ...           2 years ago
  • 4.0.0-10                                ...           2 years ago
  • 4.0.0-9                                ...           2 years ago
  • 4.0.0-8                                ...           2 years ago
  • 4.0.0-7                                ...           3 years ago
  • 4.0.0-6                                ...           3 years ago
  • 4.0.0-5                                ...           3 years ago
  • 4.0.0-4                                ...           3 years ago
  • 4.0.0-3.cf                                ...           4 years ago
  • 4.0.0-3                                ...           4 years ago
  • 4.0.0-2                                ...           4 years ago
  • 4.0.0-1                                ...           4 years ago
  • 4.0.0-0                                ...           4 years ago
  • 3.0.0-beta.2                                ...           7 years ago
  • 3.0.0-beta.1                                ...           7 years ago
  • 3.0.0-beta.0                                ...           7 years ago
  • 2.3.0 [deprecated]           ...           7 years ago
  • 2.2.1 [deprecated]           ...           8 years ago
  • 2.2.0 [deprecated]           ...           8 years ago
  • 2.1.0 [deprecated]           ...           8 years ago
  • 2.0.5 [deprecated]           ...           8 years ago
  • 2.0.4 [deprecated]           ...           8 years ago
  • 2.0.3 [deprecated]           ...           8 years ago
  • 2.0.2 [deprecated]           ...           9 years ago
  • 2.0.1 [deprecated]           ...           9 years ago
  • 2.0.0 [deprecated]           ...           9 years ago
  • 2.0.0-beta.5 [deprecated]           ...           9 years ago
  • 2.0.0-beta.4 [deprecated]           ...           9 years ago
  • 2.0.0-beta.3 [deprecated]           ...           9 years ago
  • 2.0.0-beta.2 [deprecated]           ...           9 years ago
  • 2.0.0-beta.1 [deprecated]           ...           9 years ago
  • 1.1.1                                ...           9 years ago
  • 1.1.0                                ...           9 years ago
  • 1.0.2                                ...           10 years ago
  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
  • 1.0.0-rc.3                                ...           10 years ago
  • 1.0.0-rc.2                                ...           11 years ago
  • 1.0.0-rc.1                                ...           11 years ago
  • 0.3.1                                ...           11 years ago
  • 0.3.0                                ...           11 years ago
  • 0.3.0-1                                ...           12 years ago
  • 0.2.2                                ...           12 years ago
  • 0.3.0-0                                ...           12 years ago
  • 0.2.1                                ...           12 years ago
  • 0.2.0                                ...           12 years ago
  • 0.1.8                                ...           13 years ago
  • 0.1.7                                ...           13 years ago
  • 0.1.6                                ...           14 years ago
  • 0.1.5                                ...           14 years ago
  • 0.1.4                                ...           14 years ago
  • 0.1.3                                ...           14 years ago
  • 0.1.2                                ...           14 years ago
  • 0.1.1                                ...           15 years ago
  • 0.1.0                                ...           15 years ago
Maintainers (2)
Downloads
Total 162
Today 0
This Week 13
This Month 107
Last Day 3
Last Week 29
Last Month 53
Dependencies (0)
None
Dev Dependencies (0)
None

© 2010 - cnpmjs.org x YWFE | Home | YWFE