You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@messageformat/runtime

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@messageformat/runtime

Runtime components of messageformat

3.0.1
latest
Source
npmnpm
Version published
Weekly downloads
460K
0.6%
Maintainers
1
Weekly downloads
 
Created

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

Keywords

i18n

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