🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

@messageformat/runtime

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
m

@messageformat/runtime

Runtime components of messageformat

3.0.1
latest
100

Supply Chain Security

100

Vulnerability

77

Quality

76

Maintenance

100

License

Version published
Weekly downloads
441K
-5.42%
Maintainers
1
Weekly downloads
 
Created
Issues
16

What is @messageformat/runtime?

@messageformat/runtime is a runtime library for handling message formatting in JavaScript. It allows for the creation of localized messages using ICU MessageFormat syntax, which supports pluralization, gender, and other complex message formatting needs.

What are @messageformat/runtime's main functionalities?

Basic Message Formatting

This feature allows you to create and compile basic messages with placeholders that can be replaced with dynamic values.

const { MessageFormat } = require('@messageformat/runtime');
const mf = new MessageFormat('en');
const msg = mf.compile('Hello, {name}!');
console.log(msg({ name: 'Alice' })); // Output: Hello, Alice!

Pluralization

This feature supports pluralization, allowing you to format messages differently based on the quantity of items.

const { MessageFormat } = require('@messageformat/runtime');
const mf = new MessageFormat('en');
const msg = mf.compile('{count, plural, one {# item} other {# items}}');
console.log(msg({ count: 1 })); // Output: 1 item
console.log(msg({ count: 5 })); // Output: 5 items

Gender Formatting

This feature allows for gender-based message formatting, enabling different messages based on the gender of the subject.

const { MessageFormat } = require('@messageformat/runtime');
const mf = new MessageFormat('en');
const msg = mf.compile('{gender, select, male {He} female {She} other {They}} will respond soon.');
console.log(msg({ gender: 'male' })); // Output: He will respond soon.
console.log(msg({ gender: 'female' })); // Output: She will respond soon.

Other packages similar to @messageformat/runtime

FAQs

Package last updated on 06 Feb 2022

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