Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@formatjs/intl-listformat

Package Overview
Dependencies
Maintainers
0
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@formatjs/intl-listformat

Formats JS list in a i18n-safe way

  • 7.7.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
946K
decreased by-37.7%
Maintainers
0
Weekly downloads
 
Created

What is @formatjs/intl-listformat?

The @formatjs/intl-listformat package is a JavaScript library that provides advanced list formatting capabilities. It allows developers to format lists according to the locale-specific conventions. This can include adjusting the list format for different languages and regions, handling conjunctions, disjunctions, and unit lists in a locale-aware manner.

What are @formatjs/intl-listformat's main functionalities?

Locale-aware formatting of conjunctions

This feature allows the formatting of lists using conjunctions (e.g., 'and' in English) according to the specified locale. It is useful for creating human-readable lists in user interfaces.

import { IntlListFormat } from '@formatjs/intl-listformat';

const formatter = new IntlListFormat('en', { style: 'long', type: 'conjunction' });
const formattedList = formatter.format(['Apple', 'Orange', 'Banana']);
console.log(formattedList); // Output: 'Apple, Orange, and Banana'

Locale-aware formatting of disjunctions

This feature supports formatting lists with disjunctions (e.g., 'or' in English), adapting to the locale's specific rules and preferences. It's particularly useful in contexts where choices are presented to users.

import { IntlListFormat } from '@formatjs/intl-listformat';

const formatter = new IntlListFormat('en', { style: 'long', type: 'disjunction' });
const formattedList = formatter.format(['Apple', 'Orange', 'Banana']);
console.log(formattedList); // Output: 'Apple, Orange, or Banana'

Locale-aware formatting of unit lists

This feature is designed for formatting lists of units, making it easier to display measurements and other unit-based data in a way that conforms to local customs.

import { IntlListFormat } from '@formatjs/intl-listformat';

const formatter = new IntlListFormat('en', { style: 'short', type: 'unit' });
const formattedList = formatter.format(['1 lb', '12 oz']);
console.log(formattedList); // Output: '1 lb, 12 oz'

Other packages similar to @formatjs/intl-listformat

Keywords

FAQs

Package last updated on 09 Dec 2024

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