tinganho / node-accept-language

BCP47 language negotiation
MIT License
85 stars 15 forks source link

Defaults to first language in app languages #36

Closed codechennerator closed 3 years ago

codechennerator commented 4 years ago

The module defaults to the first language of the app languages rather than en.

var acceptLanguage = require('accept-language');
acceptLanguage.languages(['cs', 'de', 'en']);
console.log(acceptLanguage.get('id')); // cs

I can see that is actually the expected behavior here: https://github.com/tinganho/node-accept-language/blob/master/Source/AcceptLanguage.ts#L65

So maybe this is a feature request, but I would expect to be able to pass all of the languages regardless of order. I would expect to be able to set my default language by myself.

tinganho commented 3 years ago

I think the current API design is nice. First is expected to be the default.