# accept-language

> Accept-Language parser for nodejs

Latest version **3.0.20** (published 2024-08-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install accept-language
pnpm add accept-language
yarn add accept-language
bun add accept-language
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.20 |
| Published | 2024-08-11 |
| First published | 2014-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 20 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 88 |
| Author | Tingan Ho |
| Maintainers | tinganho |
| Keywords | accept-language, i18n, http |

## Links

- npm: https://www.npmjs.com/package/accept-language
- Repository: https://github.com/tinganho/node-accept-language
- Issues: https://github.com/tinganho/node-accept-language/issues
- npm.io page: https://npm.io/package/accept-language

## Dependencies (1)

- [bcp47](https://npm.io/package/bcp47.md) ^1.1.2

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 3.0.20 (latest) — 2024-08-11
- 3.0.4 (next) — 2016-09-08
- 3.0.19 — 2024-08-11
- 3.0.18 — 2017-10-21
- 3.0.17 — 2017-06-11
- 3.0.16 — 2017-05-09
- 3.0.15 — 2016-09-15
- 3.0.14 — 2016-09-13
- 3.0.13 — 2016-09-13
- 3.0.12 — 2016-09-11
- 3.0.11 — 2016-09-11
- 3.0.10 — 2016-09-10
- 3.0.9 — 2016-09-09
- 3.0.8 — 2016-09-09
- 3.0.7 — 2016-09-08
- … 37 more at https://npm.io/package/accept-language/versions

## README

accept-language [![Build Status](https://travis-ci.org/tinganho/node-accept-language.png)](https://travis-ci.org/tinganho/node-accept-language)
========================

[![NPM](https://nodei.co/npm/accept-language.png?downloads=true&stars=true)](https://nodei.co/npm/accept-language/)

`accept-language` parses HTTP Accept-Language header ([BCP47][] compliant) and returns a matched defined language.

### Installation:

```
npm install accept-language --save
```

### Usage:

```ts
// var acceptLanguage = require('accept-language');
import acceptLanguage from 'accept-language';
acceptLanguage.languages(['en-US', 'zh-CN']);
console.log(acceptLanguage.get('en-GB,en;q=0.8,sv'));
/*

'en-US'

*/
```

### Usage with Express:
If you are using Express server please use the middleware [express-request-language](https://www.npmjs.com/package/express-request-language).

### API
#### acceptLanguage.languages(Array languageTags);
Provide your language tags in order of priority. The language tags must comply with [BCP47][] standard.

```javascript
acceptLanguage.languages(['en-US', 'zh-CN']);
```

#### acceptLanguage.get(String acceptLanguageString);
Returns the most likely language given an `Accept-Language` string. At least 1 language tag must be provided.
```javascript
acceptLanguage.get('en-GB,en;q=0.8,sv');
```

### Maintainer

Tingan Ho [@tingan87][]

### License
MIT

[L10ns]: http://l10ns.org
[BCP47]: https://tools.ietf.org/html/bcp47
[@tingan87]: https://twitter.com/tingan87

---
_Source: https://npm.io/package/accept-language · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
