florrain / locale

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

Best method does not return "real" best match #7

Closed benurb closed 11 years ago

benurb commented 11 years ago

Example code:

var langSupported = new locale.Locales(['de', 'en', 'fr']);
var langHeader = new locale.Locales('de_DE'); // de_DE is returned for example from german IE 10
var lang = langHeader.best(langSupported);

If I understand that correctly lang should be 'de', because it's the best match. But instead of that the default locale ('en') is returned. Maybe my understanding is wrong, but it seems logical to me to return 'de' in that case, because 'de' is a better match for 'de_DE' than 'en'. I attached a pull request, but I'm rather new to coffeescript and not entirely sure it works as designed currently and my fix is a bad fix. Maybe you can clarify that :smile:

jed commented 11 years ago

yes, i can see how this could be confusing. would love to merge in a more intuitive algorithm for choosing the best language, would you mind updating the tests so that they pass, as well as the documentation to explain how the best language is chosen?

aseemk commented 11 years ago

It looks like this was fixed some time ago and this issue/pull req is obsolete now. You may want to close it; as a new user, browsing these issues gave me the impression that this library wasn't polished yet! =)

jed commented 11 years ago

thanks for the heads up, @aseemk.