https://github.com/pirxpilot/detect-language
Finds the best matching language from Accept-Language header.
https://github.com/pirxpilot/detect-language
Last synced: 10 months ago
JSON representation
Finds the best matching language from Accept-Language header.
- Host: GitHub
- URL: https://github.com/pirxpilot/detect-language
- Owner: pirxpilot
- Created: 2015-05-09T01:16:45.000Z (about 11 years ago)
- Default Branch: main
- Last Pushed: 2025-06-05T02:40:38.000Z (about 1 year ago)
- Last Synced: 2025-09-21T14:27:37.940Z (10 months ago)
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: History.md
Awesome Lists containing this project
README
[![NPM version][npm-image]][npm-url]
[![Build Status][build-image]][build-url]
[![Dependency Status][deps-image]][deps-url]
# detect-language
Finds the best matching language from Accept-Language header.
## Install
```sh
$ npm install --save detect-language
```
## Usage
```js
var app = require('express');
var locale = {
supportedLanguages: ['de', 'fr', 'pl', 'en-GB', 'en-US'],
defaultLanguage: 'en'
};
app.use(require('./src/i18n/detect-language')(locale));
// req.lang is set to detected language
```
## License
MIT © [Damian Krzeminski](https://pirxpilot.me)
[npm-image]: https://img.shields.io/npm/v/detect-language
[npm-url]: https://npmjs.org/package/detect-language
[build-url]: https://github.com/pirxpilot/detect-language/actions/workflows/check.yaml
[build-image]: https://img.shields.io/github/actions/workflow/status/pirxpilot/detect-language/check.yaml?branch=main
[deps-image]: https://img.shields.io/librariesio/release/npm/detect-language
[deps-url]: https://libraries.io/npm/detect-language