Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

best() choose locale en when it should pick locale en_GB #38

Open
danielesegato opened this issue Jan 24, 2017 · 0 comments
Open

best() choose locale en when it should pick locale en_GB #38

danielesegato opened this issue Jan 24, 2017 · 0 comments

Comments

@danielesegato
Copy link

danielesegato commented Jan 24, 2017

Using locale version 0.1.0.

Take this example:

// classic string from a browser with both en-us and en-gb
var locs = new Locale.Locales('it-it, it;q=0.9, en-us;q=0.8, en-gb;q=0.7, en;q=0.6')
var best = locs.best(new Locale.Locales('en-gb,en,fr,de', 'en'));
best.normalized

This print: en

I would have expected en_GB since it is in the list of supported languages and it has an higher score then en (0.7 vs 0.6).

locs:

{
  '0': 
   Locale {
     code: 'it-it',
     language: 'it',
     country: 'IT',
     normalized: 'it_IT',
     score: 1 },
  '1': Locale { code: 'it', language: 'it', normalized: 'it', score: 0.9 },
  '2': 
   Locale {
     code: 'en-us',
     language: 'en',
     country: 'US',
     normalized: 'en_US',
     score: 0.8 },
  '3': 
   Locale {
     code: 'en-gb',
     language: 'en',
     country: 'GB',
     normalized: 'en_GB',
     score: 0.7 },
  '4': Locale { code: 'en', language: 'en', normalized: 'en', score: 0.6 },
  length: 5 }

if I replace en-gb with en-us in the supported list I get en-us as expected

@danielesegato danielesegato changed the title best() chose the wrong locale in some corner case best() choose the wrong locale in some corner case Jan 24, 2017
@danielesegato danielesegato changed the title best() choose the wrong locale in some corner case best() choose locale en when it should chose locale en_GB Jan 24, 2017
@danielesegato danielesegato changed the title best() choose locale en when it should chose locale en_GB best() choose locale en when it should pick locale en_GB Jan 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant