The `accept-language-parser` package provides utilities for parsing the `Accept-Language` HTTP header, which clients send to indicate their preferred human languages. It processes the header string and produces an array of language objects, each containing a `code`, optional `region`, and `quality` value, sorted in descending order of quality. Additionally, it offers a `pick` function to determine the best matching language from a list of supported languages, with an optional 'loose' matching mode. The current stable version is 1.5.0. This package appears to be in a maintenance state, as its last release was over eight years ago, suggesting infrequent updates but continued functionality. Its primary differentiation lies in its focused API for HTTP `Accept-Language` header processing, rather than a broader internationalization library.
npm install accept-language-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing an `Accept-Language` header and picking the best matching language from a supported list, including an example of loose matching.
Ensure `supportedLanguagesArray` is ordered from most specific to least specific (e.g., `['fr-CA', 'fr']`) if prioritizing specific regional variants.
In ESM environments, use `import parser from 'accept-language-parser';` and then access methods like `parser.parse()` or `parser.pick()`.
Consider reviewing the source code for any potential issues if integrating into a critical system, or evaluate alternatives if active maintenance and modern features are a high priority.
Change the import to `import parser from 'accept-language-parser';` and access `parser.parse()` or `parser.pick()`.
Run `npm install accept-language-parser` or `yarn add accept-language-parser` in your project directory.
No dependency data recorded yet.