Package Exports
- accept-language
- accept-language/Build/Source/AcceptLanguage.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (accept-language) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
accept-language 
accept-language
parses HTTP Accept-Language header (BCP47 compliant) and returns a matched defined language.
Installation:
npm install accept-language --save
Usage:
// 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.
API
acceptLanguage.languages(Array languageTags);
Provide your language tags in order of priority. The language tags must comply with BCP47 standard.
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.
acceptLanguage.get('en-GB,en;q=0.8,sv');
Maintainer
Tingan Ho @tingan87
License
MIT