You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

intl-messageformat-parser

Package Overview
Dependencies
Maintainers
6
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

intl-messageformat-parser

Parses ICU Message strings into an AST via JavaScript.


Version published
Weekly downloads
1.1M
decreased by-18.65%
Maintainers
6
Install size
799 kB
Created
Weekly downloads
 

Package description

What is intl-messageformat-parser?

The intl-messageformat-parser package is a tool for parsing ICU MessageFormat strings into an Abstract Syntax Tree (AST). This is useful for internationalization (i18n) as it allows developers to handle complex message formatting in a structured way.

What are intl-messageformat-parser's main functionalities?

Parsing MessageFormat Strings

This feature allows you to parse a MessageFormat string into an AST. The AST can then be used for further processing or manipulation.

const { parse } = require('intl-messageformat-parser');
const message = 'Hello, {name}! You have {numMessages, plural, one {# message} other {# messages}}.';
const ast = parse(message);
console.log(JSON.stringify(ast, null, 2));

Handling Pluralization

This feature allows you to handle pluralization in messages. The parser can interpret plural rules and convert them into an AST.

const { parse } = require('intl-messageformat-parser');
const message = '{num, plural, one {# item} other {# items}}';
const ast = parse(message);
console.log(JSON.stringify(ast, null, 2));

Handling SelectFormat

This feature allows you to handle select format in messages. The parser can interpret select rules and convert them into an AST.

const { parse } = require('intl-messageformat-parser');
const message = '{gender, select, male {He} female {She} other {They}} will respond soon.';
const ast = parse(message);
console.log(JSON.stringify(ast, null, 2));

Other packages similar to intl-messageformat-parser

Readme

Source

Intl MessageFormat Parser

We've migrated the docs to https://formatjs.io/docs/intl-messageformat-parser.

Keywords

FAQs

Package last updated on 26 Mar 2021

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc