Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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
  • npm
  • Socket score

Version published
Maintainers
1
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

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc