tinganho / node-accept-language

BCP47 language negotiation
MIT License
85 stars 15 forks source link

Updated the docs to reflect the instance creation ability #14

Closed rhagigi closed 8 years ago

tinganho commented 8 years ago

They shouldn't use it. It accidentally got exported.

rhagigi commented 8 years ago

I disagree. For one, what if you have multiple routes needing different default languages or supporting different languages? Second, using module caching as your instance creation and config mechanism is an anti pattern as an npm module... You may be used by other modules that may want to set their own defaults/supported languages... Now that would bleed into any apps using those modules.

chearmstrong commented 6 years ago

Hi @tinganho - I seem to have been caught out by this... I'm using this module in 2x places and passing in an array of supported languages in each case. In each of the 2x places, the supported languages are different. However, the issue is that I can only have one configuration of support languages, causing me some issues.

How can I fix this?

chearmstrong commented 6 years ago

Is there any issue in doing this in each file I need to support a set of different languages?

const acceptLanguage = require('accept-language').create();

tinganho commented 6 years ago

@chearmstrong that should do what you want.

chearmstrong commented 6 years ago

Great, thanks.