JSPM

  • Created
  • Published
  • Downloads 217726
  • Score
    100M100P100Q219860F
  • License MIT

Accept-Language parser for nodejs

Package Exports

  • accept-language

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 Build Status

NPM

accept-language parses HTTP Accept-Language header and returns a matched defined language.

Installation:

npm install accept-language --save

Usage:

const acceptLanguage = require('accept-language');
acceptLanguage.languages(['en-US', 'zh-CN']);
console.log(acceptLanguage.get('en-GB,en;q=0.8,sv'));
/*

'en-US'

*/

L10ns is an internationalization workflow and formatting tool. This library was specifically built for L10ns. L10ns is a very good alternative to Gettext and all of it's tooling support–XGettext, PoEdit, custom libraries etc.

API

acceptLanguage.languages(Array languageTags);

Define your language tags ordered in highest priority comes first fashion. The language tags must comply with BCP47 standard.

acceptLanguage.languages(['en-US', 'zh-CN']);

acceptLanguage.get(String acceptLanguageString);

Get the most likely language given an Accept-Language string. In order for it to work you must set all your languages first.

acceptLanguage.get('en-GB,en;q=0.8,sv');

Maintainer

Tingan Ho @tingan87

License

MIT