florrain / locale

Browser locale negotiation for node.js
MIT License
257 stars 36 forks source link

best do not work correctly with Norwegian locale #41

Closed moimael closed 7 years ago

moimael commented 7 years ago

Hi,

Norwegian has multiple iso code that are not similar: no - Norwegian nb - Norwegian Bokmål nn - Norwegian Nynorsk

So best do not seems to work. For example when I set nb or nn it doesn't pick no.

Thanks.

florrain commented 7 years ago

Hi @moimael - Sorry for the late answer. To me that sounds like a case where the fallback strategy doesn't fit with the country's culture unfortunately, here because the country has multiple official languages. Same thing with Switzerland for example where it-CH, de-CH, fr-CH are correct.

The solution would be to declare the different languages in the supported locales that you pass to best like:

    const supportedLocales = new locale.Locales(['no', 'nb', 'nn']);
    assert.equal(new locale.Locales('nb-NO').best(supportedLocales), 'nb');

Let me know if I can help more. I'm going to close the issue.