{"id":15429528,"url":"https://github.com/wooorm/bcp-47-normalize","last_synced_at":"2025-04-15T22:53:57.442Z","repository":{"id":50623406,"uuid":"242571629","full_name":"wooorm/bcp-47-normalize","owner":"wooorm","description":"Normalize, canonicalize, and format BCP 47 tags","archived":false,"fork":false,"pushed_at":"2023-11-01T12:10:42.000Z","size":206,"stargazers_count":22,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-15T22:53:51.518Z","etag":null,"topics":["47","bcp","bcp47","canonical","code","format","i18n","iana","language","language-tags","normal","subtags","tag"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wooorm.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":"funding.yml","license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"wooorm"}},"created_at":"2020-02-23T18:46:30.000Z","updated_at":"2024-09-16T21:23:04.000Z","dependencies_parsed_at":"2024-06-18T17:07:02.070Z","dependency_job_id":"3e1be1ac-e1dd-4515-9ad5-c2174d5f2536","html_url":"https://github.com/wooorm/bcp-47-normalize","commit_stats":{"total_commits":45,"total_committers":3,"mean_commits":15.0,"dds":0.0444444444444444,"last_synced_commit":"d192c42eed1a24998878ae34c927afa74619ac81"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fbcp-47-normalize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fbcp-47-normalize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fbcp-47-normalize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fbcp-47-normalize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wooorm","download_url":"https://codeload.github.com/wooorm/bcp-47-normalize/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249167439,"owners_count":21223505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["47","bcp","bcp47","canonical","code","format","i18n","iana","language","language-tags","normal","subtags","tag"],"created_at":"2024-10-01T18:11:23.866Z","updated_at":"2025-04-15T22:53:57.424Z","avatar_url":"https://github.com/wooorm.png","language":"JavaScript","funding_links":["https://github.com/sponsors/wooorm"],"categories":[],"sub_categories":[],"readme":"# bcp-47-normalize\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n\nNormalize, canonicalize, and format [BCP 47][spec] tags.\n\n## Contents\n\n*   [What is this?](#what-is-this)\n*   [When should I use this?](#when-should-i-use-this)\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n    *   [`bcp47Normalize(tag[, options])`](#bcp47normalizetag-options)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Security](#security)\n*   [Related](#related)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis package takes BCP 47 tags and makes them uniform.\nIt removes unneeded info (`en-us` -\u003e `en`) and replaces deprecated,\noverlong, and otherwise unpreferred values with preferred values\n(`en-bu` -\u003e `en-MM`).\nIt works by applying [Unicode CLDR suggestions][alias].\n\n## When should I use this?\n\nYou can use this package when dealing with user-provided language tags and want\nto normalize and clean them.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 14.14+, 16.0+), install with [npm][]:\n\n```sh\nnpm install bcp-47-normalize\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {bcp47Normalize} from 'https://esm.sh/bcp-47-normalize@2'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import {bcp47Normalize} from 'https://esm.sh/bcp-47-normalize@2?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\n```js\nimport {bcp47Normalize} from 'bcp-47-normalize'\n\nconst tags = [\n  'de-de-1901',\n  'en-gb',\n  'en-us',\n  'en-bu',\n  'hy-arevmda',\n  'nld-nl',\n  'no-nyn',\n  'pt-br',\n  'pt-pt',\n  'zh-hans-cn'\n]\n\ntags.forEach((tag) =\u003e console.log('%s -\u003e %s', tag, bcp47Normalize(tag)))\n```\n\nYields:\n\n```txt\nde-de-1901 -\u003e de-1901\nen-gb -\u003e en-GB\nen-us -\u003e en\nen-bu -\u003e en-MM\nhy-arevmda -\u003e hyw\nnld-nl -\u003e nl\nno-nyn -\u003e nn\npt-br -\u003e pt\npt-pt -\u003e pt-PT\nzh-hans-cn -\u003e zh\n```\n\n## API\n\nThis package exports the identifier `bcp47Normalize`.\nThere is no default export.\n\n### `bcp47Normalize(tag[, options])`\n\nNormalize the given BCP 47 tag according to [Unicode CLDR suggestions][alias].\n\n###### Parameters\n\n*   `tag` (`string`)\n    — BCP 47 tag\n*   `options.forgiving` (`boolean`, default: `false`)\n    — passed to `bcp-47` as [`options.forgiving`][forgiving]\n*   `options.warning` (`Function?`, default: `undefined`)\n    — passed to `bcp-47` as [`options.warning`][warning]\n\n    One additional warning is given:\n\n    | code | reason                                                     |\n    | :--- | :--------------------------------------------------------- |\n    | 7    | Deprecated region `CURRENT`, expected one of `SUGGESTIONS` |\n\n    This warning is only given if the region cannot be automatically fixed (when\n    regions split into multiple regions).\n\n###### Returns\n\nNormal, canonical, and pretty [BCP 47][spec] tag (`string`).\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional types `Options` and `Warning`.\n\n## Compatibility\n\nThis package is at least compatible with all maintained versions of Node.js.\nAs of now, that is Node.js 14.14+ and 16.0+.\nIt also works in Deno and modern browsers.\n\n## Security\n\nThis package is safe.\n\n## Related\n\n*   [`wooorm/bcp-47`](https://github.com/wooorm/bcp-47)\n    — parse and stringify BCP 47 language tags\n*   [`wooorm/bcp-47-match`](https://github.com/wooorm/bcp-47-match)\n    — match BCP 47 language tags with language ranges per RFC 4647\n*   [`wooorm/iso-3166`](https://github.com/wooorm/iso-3166)\n    — ISO 3166 codes\n*   [`wooorm/iso-639-2`](https://github.com/wooorm/iso-639-2)\n    — ISO 639-2 codes\n*   [`wooorm/iso-639-3`](https://github.com/wooorm/iso-639-3)\n    — ISO 639-3 codes\n*   [`wooorm/iso-15924`](https://github.com/wooorm/iso-15924)\n    — ISO 15924 codes\n*   [`wooorm/un-m49`](https://github.com/wooorm/un-m49)\n    — UN M49 codes\n\n## Contribute\n\nYes please!\nSee [How to Contribute to Open Source][contribute].\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n\u003c!-- Definitions --\u003e\n\n[build-badge]: https://github.com/wooorm/bcp-47-normalize/workflows/main/badge.svg\n\n[build]: https://github.com/wooorm/bcp-47-normalize/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/bcp-47-normalize.svg\n\n[coverage]: https://codecov.io/github/wooorm/bcp-47-normalize\n\n[downloads-badge]: https://img.shields.io/npm/dm/bcp-47-normalize.svg\n\n[downloads]: https://www.npmjs.com/package/bcp-47-normalize\n\n[size-badge]: https://img.shields.io/bundlephobia/minzip/bcp-47-normalize.svg\n\n[size]: https://bundlephobia.com/result?p=bcp-47-normalize\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esmsh]: https://esm.sh\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[typescript]: https://www.typescriptlang.org\n\n[contribute]: https://opensource.guide/how-to-contribute/\n\n[spec]: https://tools.ietf.org/rfc/bcp/bcp47.html\n\n[alias]: https://github.com/unicode-org/cldr/blob/142b327/common/supplemental/supplementalMetadata.xml#L32\n\n[forgiving]: https://github.com/wooorm/bcp-47#optionsforgiving\n\n[warning]: https://github.com/wooorm/bcp-47#optionswarning\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwooorm%2Fbcp-47-normalize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwooorm%2Fbcp-47-normalize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwooorm%2Fbcp-47-normalize/lists"}