jed/locale — pull request #24 by mlmorg (2014-07-08 00:35:14+00:00)
Title: Match country-specific language codes when separator is different

My last PR (#23) introduced a regression whereby two locales with the same language and country codes but a different separator ("-" vs. "_") would not correctly match. An example of how this can happen:

```js
var userLocales = new locale.Locales(['en_US']);
var supportedLocales = new locale.Locales(['en', 'en-US']);
var bestLocale = userLocales.best(supportedLocales).toString(); // returns `en` instead of `en-US`
```

This happened because the `best()` method was matching locales based on their `toString()` values, which now returns the original code (instead of one always separated with an "_").

This PR fixes that bug by introducing a normalized attribute on the `Locale` specifically for use when matching locales using `best()`. In addition, I altered the `index()` method on `Locales` to map the locale code to the array index at which that `Locale` object is located in the supported locales array passed in to `best()` so that we could return the original `Locale` object passed in.

Let me know if you have any questions and sorry for the regression.