Socket
Socket
Sign inDemoInstall

bcp-47-normalize

Package Overview
Dependencies
5
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    bcp-47-normalize

Normalize, canonicalize, and format BCP 47 tags


Version published
Maintainers
1
Install size
126 kB
Created

Readme

Source

bcp-47-normalize

Build Coverage Downloads Size

Normalize, canonicalize, and format BCP 47 tags.

Install

npm:

npm install bcp-47-normalize

Use

var normalize = require('bcp-47-normalize')

var tags = [
  'de-de-1901',
  'en-gb',
  'en-us',
  'en-bu',
  'hy-arevmda',
  'nld-nl',
  'no-nyn',
  'pt-br',
  'pt-pt',
  'zh-hans-cn'
]

tags.forEach(function(tag) {
  console.log('%s -> %s', tag, normalize(tag))
})

Yields:

de-de-1901 -> de-1901
en-gb -> en-GB
en-us -> en
en-bu -> en-MM
hy-arevmda -> hyw
nld-nl -> nl
no-nyn -> nn
pt-br -> pt
pt-pt -> pt-PT
zh-hans-cn -> zh-CN

API

normalize(tag[, options])

Normalize the given BCP 47 tag according to Unicode CLDR suggestions.

options.forgiving

Passed to bcp-47 as options.forgiving.

options.warning

Passed to bcp-47 as options.warning.

One additional warning is given:

codereason
7Deprecated region CURRENT, expected one of SUGGESTIONS

This warning is only given if the region cannot be automatically fixed (when regions split into multiple regions).

Returns

string — Normal, canonical, and pretty BCP 47 tag.

  • bcp-47 — Parse and stringify BCP 47 language tags
  • bcp-47-match — Match BCP 47 language tags with language ranges per RFC 4647
  • iso-3166 — ISO 3166 codes
  • iso-639-2 — ISO 639-2 codes
  • iso-639-3 — ISO 639-3 codes
  • iso-15924 — ISO 15924 codes
  • un-m49 — UN M49 codes

License

MIT © Titus Wormer

Keywords

FAQs

Last updated on 24 Jul 2020

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc