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.
[![Maintainability](https://api.codeclimate.com/v1/badges/1ff0c28615640d86e758/maintainability)](https://codeclimate.com/github/flexper/rosetty/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/1ff0c28615640d86e758/test_coverage)](h
Complete Intl/I18n solution for browser and node
const { rosetty, locales } = require('rosetty');
const { enGB: enLocale } = locales;
const r = rosetty(
{
en: {
dict: {
test: 'This is a test',
},
locale: enLocale,
},
},
'en'
);
console.log(r.t('test')); // This is a test
Options
Field Name | Type | Description |
---|---|---|
config | Record<string, Language> | Specify dictionnary and locale to use for each lang |
defaultLang | string? | Specify default language to use (should be the same as config) |
Return
Field Name | Type | Description |
---|---|---|
changeLang | (newLang: string) => void | Change current lang |
languages | string[] | List of languages who can be selected |
getCurrentLang | () => string | Return current lang |
t | (key: string, params?: Record<string, any>) => string OR undefined | Return translated text https://github.com/lukeed/rosetta#rosettatkey-params-lang |
displayNames | Documentation | Consistent translation of language, region and script display names https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames |
listFormat | Documentation | Language-sensitive list formatting https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat |
numberFormat | Documentation | Language-sensitive list formatting https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat |
pluralRules | Documentation | Plural-sensitive formatting and plural-related language rules https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/PluralRules |
format | Documentation | Return the formatted date string in the given format https://date-fns.org/v2.28.0/docs/format |
formatRelative | Documentation | Represent the date in words relative to the given base date. https://date-fns.org/v2.28.0/docs/formatRelative |
formatDistance | Documentation | Return the distance between the given dates in words. https://date-fns.org/v2.28.0/docs/formatDistance |
formatDistanceToNow | Documentation | Return the distance between the given date and now in words. https://date-fns.org/v2.28.0/docs/formatDistanceToNow |
formatDuration | Documentation | Return human-readable duration string i.e. "9 months 2 days" https://date-fns.org/v2.28.0/docs/formatDuration |
Return: Record<string, Locale>
Return Date-fns locale files. https://date-fns.org/v2.28.0/docs/Locale
You need to load polyfill on node environment because Intl API is not present. Please use below code to make it works.
/* eslint-disable @typescript-eslint/ban-ts-comment */
/* eslint-disable no-empty */
export const loadPolyfill = () => {
//@ts-ignore
if (!Intl?.DisplayNames) {
require(`@formatjs/intl-displaynames/polyfill`);
}
//@ts-ignore
if (!Intl?.ListFormat) {
require(`@formatjs/intl-listformat/polyfill-force`);
}
//@ts-ignore
if (!Intl?.NumberFormat) {
require(`@formatjs/intl-numberformat/polyfill`);
}
//@ts-ignore
if (!Intl?.PluralRules) {
require(`@formatjs/intl-pluralrules/polyfill`);
}
};
export const loadPolyfillData = (lang: string) => {
//Load Lang polyfill
try {
require(`@formatjs/intl-displaynames/locale-data/${lang}`);
} catch (error) {}
try {
require(`@formatjs/intl-listformat/locale-data/${lang}`);
} catch (error) {}
try {
require(`@formatjs/intl-numberformat/locale-data/${lang}`);
} catch (error) {}
try {
require(`@formatjs/intl-pluralrules/locale-data/${lang}`);
} catch (error) {}
//Load Lang polyfill fallback
try {
require(`@formatjs/intl-displaynames/locale-data/${lang.split('-')[0]}`);
} catch (error) {}
try {
require(`@formatjs/intl-listformat/locale-data/${lang.split('-')[0]}`);
} catch (error) {}
try {
require(`@formatjs/intl-numberformat/locale-data/${lang.split('-')[0]}`);
} catch (error) {}
try {
require(`@formatjs/intl-pluralrules/locale-data/${lang.split('-')[0]}`);
} catch (error) {}
};
This package use TSdx. Please check documentation to update this package.
FAQs
[![Maintainability](https://api.codeclimate.com/v1/badges/1ff0c28615640d86e758/maintainability)](https://codeclimate.com/github/qlaffont/rosetty/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/1ff0c28615640d86e758/test_coverage)](
The npm package rosetty receives a total of 860 weekly downloads. As such, rosetty popularity was classified as not popular.
We found that rosetty demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.