Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit 03bac26

Browse files
authored
Merge pull request #28 from piperchester/patch-1
Update README.md
2 parents 54c9f49 + 0cf4d42 commit 03bac26

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

README.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Parses the accept-language header from an HTTP request and produces an array of
88

99
### Installation:
1010

11-
```
11+
```bash
1212
npm install accept-language-parser
1313
```
1414

@@ -41,13 +41,13 @@ Output will be:
4141
];
4242
```
4343

44-
Output is always sorted in quality order from highest -> lowest. as per the http spec, omitting the quality value implies 1.0.
44+
Output is always sorted in quality order from highest -> lowest. As per the HTTP spec, omitting the quality value implies 1.0.
4545

4646
#### parser.pick(supportedLangugagesArray, acceptLanguageHeader, options = {})
4747

4848
*Alias*: parser.pick(supportedLanguagesArray, parsedAcceptLanguageHeader)
4949

50-
```
50+
```javascript
5151
var parser = require('accept-language-parser');
5252

5353
var language = parser.pick(['fr-CA', 'fr-FR', 'fr'], 'en-GB,en-US;q=0.9,fr-CA;q=0.7,en;q=0.8');
@@ -57,27 +57,34 @@ console.log(language);
5757

5858
Output will be:
5959

60-
```
60+
```javascript
6161
"fr-CA"
6262
```
6363

64-
The `options` currently supports only `loose` option that allows partial matching on supported languages. For example:
64+
The `options` currently supports only the `loose` option which allows partial matching on supported languages.
6565

66+
For example:
6667

67-
```
68+
```javascript
6869
parser.pick(['fr', 'en'], 'en-GB,en-US;q=0.9,fr-CA;q=0.7,en;q=0.8', { loose: true });
6970
```
7071

7172
Would return:
7273

73-
```
74+
```javascript
7475
"fr"
7576
```
7677

77-
In loose mode the order of `supportedLanguagesArray` matters, as it is the first partially matching language that is returned. It means that if you want to pick more specific langauge first, you should list it first as well, for example: `['fr-CA', 'fr']`.
78+
In loose mode the order of `supportedLanguagesArray` matters, as it is the first partially matching language that is returned. It means that if you want to pick more specific langauges first, you should list it first as well.
7879

79-
### Running test
80+
For example:
81+
```javascript
82+
['fr-CA', 'fr']
8083
```
84+
85+
### Running test
86+
87+
```bash
8188
npm install
8289
npm test
8390
```

0 commit comments

Comments
 (0)