Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@formatjs/intl-localematcher
Advanced tools
The @formatjs/intl-localematcher package is designed to help with locale matching based on the Best Fit Matcher algorithm as specified by the ECMAScript Internationalization API. It allows developers to determine the best available locale for their application based on a list of desired locales and a list of supported locales. This can be particularly useful in internationalization (i18n) efforts where applications need to gracefully handle multiple languages and regional differences.
Locale Matching
This feature allows you to match a list of desired locales against a list of supported locales to find the best match. It uses the Best Fit Matcher algorithm to determine the most appropriate locale for the user.
"use strict";
const {getCanonicalLocales, match} = require('@formatjs/intl-localematcher');
const supportedLocales = ['en-US', 'fr-FR', 'es-ES'];
const desiredLocales = ['en-GB', 'en'];
const bestMatch = match(desiredLocales, supportedLocales);
console.log(bestMatch); // 'en-US'
The 'locale' package provides similar functionalities for locale detection and negotiation. It can parse, normalize, and match locales using different strategies. Compared to @formatjs/intl-localematcher, 'locale' offers a broader set of features for handling locales but might not specifically implement the Best Fit Matcher algorithm as defined by ECMAScript.
This package is designed to parse the Accept-Language header from an HTTP request and match it against a list of supported languages. While it serves a similar purpose in determining the best language for the user, it is more focused on the context of HTTP requests and does not directly implement the ECMAScript Internationalization API's Best Fit Matcher algorithm.
We've migrated the docs to https://formatjs.io/docs/polyfills/intl-localematcher.
FAQs
Intl.LocaleMatcher ponyfill
The npm package @formatjs/intl-localematcher receives a total of 3,324,228 weekly downloads. As such, @formatjs/intl-localematcher popularity was classified as popular.
We found that @formatjs/intl-localematcher demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.