Socket
Book a DemoInstallSign in
Socket

messageformat

Package Overview
Dependencies
Maintainers
2
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

messageformat

Intl.MessageFormat / Unicode MessageFormat 2 parser, runtime and polyfill

latest
Source
npmnpm
Version
4.0.0
Version published
Weekly downloads
276K
66.58%
Maintainers
2
Weekly downloads
 
Created
Source

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 (October 2025) version of the MF2 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.

Keywords

messageformat

FAQs

Package last updated on 25 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts