Gathering detailed insights and metrics for bcp-47-normalize
Gathering detailed insights and metrics for bcp-47-normalize
Gathering detailed insights and metrics for bcp-47-normalize
Gathering detailed insights and metrics for bcp-47-normalize
npm install bcp-47-normalize
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
22 Stars
45 Commits
1 Forks
2 Watchers
1 Branches
3 Contributors
Updated on Sep 16, 2024
Latest Version
2.3.0
Package Id
bcp-47-normalize@2.3.0
Unpacked Size
255.92 kB
Size
65.04 kB
File Count
15
NPM Version
9.7.2
Node Version
20.0.0
Published on
Jul 17, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Normalize, canonicalize, and format BCP 47 tags.
This package takes BCP 47 tags and makes them uniform.
It removes unneeded info (en-us
-> en
) and replaces deprecated,
overlong, and otherwise unpreferred values with preferred values
(en-bu
-> en-MM
).
It works by applying Unicode CLDR suggestions.
You can use this package when dealing with user-provided language tags and want to normalize and clean them.
This package is ESM only. In Node.js (version 14.14+, 16.0+), install with npm:
1npm install bcp-47-normalize
In Deno with esm.sh
:
1import {bcp47Normalize} from 'https://esm.sh/bcp-47-normalize@2'
In browsers with esm.sh
:
1<script type="module"> 2 import {bcp47Normalize} from 'https://esm.sh/bcp-47-normalize@2?bundle' 3</script>
1import {bcp47Normalize} from 'bcp-47-normalize' 2 3const tags = [ 4 'de-de-1901', 5 'en-gb', 6 'en-us', 7 'en-bu', 8 'hy-arevmda', 9 'nld-nl', 10 'no-nyn', 11 'pt-br', 12 'pt-pt', 13 'zh-hans-cn' 14] 15 16tags.forEach((tag) => console.log('%s -> %s', tag, bcp47Normalize(tag)))
Yields:
1de-de-1901 -> de-1901 2en-gb -> en-GB 3en-us -> en 4en-bu -> en-MM 5hy-arevmda -> hyw 6nld-nl -> nl 7no-nyn -> nn 8pt-br -> pt 9pt-pt -> pt-PT 10zh-hans-cn -> zh
This package exports the identifier bcp47Normalize
.
There is no default export.
bcp47Normalize(tag[, options])
Normalize the given BCP 47 tag according to Unicode CLDR suggestions.
tag
(string
)
— BCP 47 tag
options.forgiving
(boolean
, default: false
)
— passed to bcp-47
as options.forgiving
options.warning
(Function?
, default: undefined
)
— passed to bcp-47
as options.warning
One additional warning is given:
code | reason |
---|---|
7 | Deprecated region CURRENT , expected one of SUGGESTIONS |
This warning is only given if the region cannot be automatically fixed (when regions split into multiple regions).
Normal, canonical, and pretty BCP 47 tag (string
).
This package is fully typed with TypeScript.
It exports the additional types Options
and Warning
.
This package is at least compatible with all maintained versions of Node.js. As of now, that is Node.js 14.14+ and 16.0+. It also works in Deno and modern browsers.
This package is safe.
wooorm/bcp-47
— parse and stringify BCP 47 language tagswooorm/bcp-47-match
— match BCP 47 language tags with language ranges per RFC 4647wooorm/iso-3166
— ISO 3166 codeswooorm/iso-639-2
— ISO 639-2 codeswooorm/iso-639-3
— ISO 639-3 codeswooorm/iso-15924
— ISO 15924 codeswooorm/un-m49
— UN M49 codesYes please! See How to Contribute to Open Source.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 2/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More