
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
accept-locale
Advanced tools
accept-locale
parses HTTP Accept-Language header and returns a consumable array of locale data.
I thought before that languages
where a subset of locales
, thus I created this library. I made a mistake about language
vs. locale
naming. After some research language tags
are not synonymous with just language
. The name locale
was used widely before the usage of language tags
for major i18n libraries. There is one major difference between language tags and locale identifiers and that is explained by w3c:
A major difference between language tags and locale identifiers is the meaning of the region code. In both language tags and locales, the region code indicates variation in language (as with regional dialects) or presentation and format (such as number or date formats). In a locale, the region code is also sometimes used to indicate the physical location, market, legal, or other governing policies for the user.
Many libraries use the BCP47 language tags. Since this standard refer to language tags
or just language
– I decided to deprecate this library, because of naming confusions. Please use accept-language instead.
Sorry for any problems I caused with this change.
npm install accept-locale --save
var acceptLocale = require('accept-locale');
var locale = acceptLocale.parse('en-GB,en;q=0.8,sv');
console.log(locale);
Output:
[
{
language: "en",
region: "GB",
quality: 1.0
},
{
language: "sv",
region: undefined,
quality: 1.0
},
{
language: "en",
region: undefined,
quality: 0.8
}
];
Filter non-defined language codes:
var acceptLocale = require('accept-locale');
acceptLocale.codes(['en', 'zh']);
var locale = acceptLocale.parse('en-GB,en;q=0.8,sv');
console.log(locale);
Output:
[
{
language: "en",
region: "GB",
quality: 1.0
},
{
language: "en",
region: undefined,
quality: 0.8
}
];
Use default value:
var acceptLocale = require('accept-locale');
acceptLocale.default({
language : 'en',
region : 'US'
// No need to specify quality
});
acceptLocale.codes(['en', 'zh']);
var locale = acceptLocale.parse('fr-CA');
console.log(locale);
Output:
[
{
language: "en",
region: "US",
quality: 1.0
}
];
The output is always sorted with the highest quality first.
FAQs
HTTP Accept-Language parser for node
The npm package accept-locale receives a total of 0 weekly downloads. As such, accept-locale popularity was classified as not popular.
We found that accept-locale demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.