Socket
Socket
Sign inDemoInstall

intl-messageformat

Package Overview
Dependencies
6
Maintainers
12
Versions
260
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    intl-messageformat

Formats ICU Message strings with number, date, plural, and select placeholders to create localized messages.


Version published
Weekly downloads
3.3M
decreased by-17.31%
Maintainers
12
Install size
1.54 MB
Created
Weekly downloads
 

Package description

What is intl-messageformat?

The intl-messageformat package is a library for internationalization that allows formatting of messages including variable replacement, number and date formatting, and pluralization. It is built on the Internationalization API provided by modern browsers and can be used in both browser and Node.js environments.

What are intl-messageformat's main functionalities?

Variable Replacement

This feature allows you to insert variables into your message strings.

const IntlMessageFormat = require('intl-messageformat').default;
const message = new IntlMessageFormat('My name is {name}.');
const output = message.format({ name: 'Alice' });
console.log(output); // 'My name is Alice.'

Number Formatting

This feature allows you to format numbers according to the locale, including decimal and thousand separators.

const IntlMessageFormat = require('intl-messageformat').default;
const message = new IntlMessageFormat('The price is {price, number}.', 'en-US');
const output = message.format({ price: 123456.78 });
console.log(output); // 'The price is 123,456.78.'

Date Formatting

This feature allows you to format dates according to the locale.

const IntlMessageFormat = require('intl-messageformat').default;
const message = new IntlMessageFormat('Today is {today, date, long}.', 'en-US');
const output = message.format({ today: new Date() });
console.log(output); // 'Today is January 1, 2020.'

Pluralization

This feature allows you to handle plural forms of words based on numeric values.

const IntlMessageFormat = require('intl-messageformat').default;
const message = new IntlMessageFormat('{numPhotos, plural, =0{no photos} =1{one photo} other{# photos}}', 'en-US');
const output = message.format({ numPhotos: 1000 });
console.log(output); // '1000 photos'

Other packages similar to intl-messageformat

Readme

Source

Intl MessageFormat

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

Keywords

FAQs

Last updated on 26 Jan 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc