accept-language
Advanced tools
Comparing version 2.0.17 to 3.0.0
{ | ||
"name": "accept-language", | ||
"version": "2.0.17", | ||
"description": "HTTP Accept-Language parser for node", | ||
"main": "index.js", | ||
"version": "3.0.0", | ||
"description": "Accept-Language parser for nodejs", | ||
"main": "Build/Source/AcceptLanguage.js", | ||
"scripts": { | ||
"test": "./binaries/test" | ||
"test": "node node_modules/mocha/bin/mocha Build/Tests/Test.js" | ||
}, | ||
"types": "Library/Typings.d.ts", | ||
"repository": { | ||
@@ -16,3 +17,3 @@ "type": "git", | ||
"i18n", | ||
"parser" | ||
"http" | ||
], | ||
@@ -26,6 +27,6 @@ "author": "Tingan Ho <tingan87@gmail.com>", | ||
"devDependencies": { | ||
"sinon": "~1.9.1", | ||
"sinon-chai": "~2.5.0", | ||
"mocha": "^2.2.5", | ||
"chai": "~1.9.1" | ||
"chai": "~1.9.1", | ||
"@types/chai": "^3.4.32", | ||
"@types/mocha": "^2.2.31" | ||
}, | ||
@@ -32,0 +33,0 @@ "dependencies": { |
@@ -6,3 +6,3 @@ accept-language [![Build Status](https://travis-ci.org/tinganho/node-accept-language.png)](https://travis-ci.org/tinganho/node-accept-language) | ||
`accept-language` parses HTTP Accept-Language header and returns the most likely language or a consumable array of languages. | ||
`accept-language` parses HTTP Accept-Language header and returns a matched defined language. | ||
@@ -18,3 +18,3 @@ ### Installation: | ||
```javascript | ||
var acceptLanguage = require('accept-language'); | ||
const acceptLanguage = require('accept-language'); | ||
acceptLanguage.languages(['en-US', 'zh-CN']); | ||
@@ -27,36 +27,10 @@ console.log(acceptLanguage.get('en-GB,en;q=0.8,sv')); | ||
*/ | ||
var language = acceptLanguage.parse('en-GB,en;q=0.8,sv'); | ||
console.log(language); | ||
/* | ||
[ | ||
{ | ||
value: 'en-US', | ||
language: "en", | ||
region: "US", | ||
quality: 1.0 | ||
} | ||
]; | ||
*/ | ||
``` | ||
### Recommended usage with L10ns: | ||
[L10ns][] is an internationalization workflow and formatting tool. This library was specifically built for [L10ns](http://l10ns.org). [L10ns][] is a very good alternative to Gettext and all of it's tooling support–XGettext, PoEdit, custom libraries etc. | ||
[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. The [BCP47][] language tag consist of at least the following subtags: | ||
Define your language tags ordered in highest priority comes first fashion. The language tags must comply with [BCP47][] standard. | ||
1. A language subtag (`en`, `zh`). | ||
3. A script subtag (`Hant`, `Latn`). | ||
2. A region subtag (`US`, `CN`). | ||
Then language tag has the following syntax: | ||
``` | ||
language[-script][-region] | ||
``` | ||
Which makes the following language tags `en`, `en-US` and `zh-Hant-TW` all [BCP47][] compliant. Please note that the script tag refers to language script. Some languages use two character sets instead of one. Chinese is a good example of having two character sets instead of one–it has both traditional characters and simplified characters. And for popular languages that uses two or more scripts please specify the script subtag, because it can make an i18n library fetch more specific locale data. | ||
```javascript | ||
@@ -72,8 +46,2 @@ acceptLanguage.languages(['en-US', 'zh-CN']); | ||
#### acceptLanguage.parse(String acceptLanguageString); | ||
Parse an `Accept-Language` string and get a consumable array of languages. In order for it to work you must set all your language tags first. | ||
```javascript | ||
acceptLanguage.parse('en-GB,en;q=0.8,sv'); | ||
``` | ||
### Maintainer | ||
@@ -80,0 +48,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6
9767
151
53
1