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

getBestMatchingLanguage should return null as a last resort #194

Open
1ec5 opened this issue Nov 23, 2017 · 0 comments
Open

getBestMatchingLanguage should return null as a last resort #194

1ec5 opened this issue Nov 23, 2017 · 0 comments

Comments

@1ec5
Copy link
Member

1ec5 commented Nov 23, 2017

getBestMatchingLanguage() currently returns en for English if all the other fallbacks have been exhausted. Instead, it should return null as a last resort.

return 'en';

The current behavior is problematic, because the caller may not know whether this method returned en because it’s the best match or because there’s no other option. A client may want to use this method with a list of acceptable languages, such as navigator.languages, stopping only when a match is found. With the current behavior, the client would have to either ignore every language after the first one (because this method always returns a value) or ignore every language other than English (because this method uses English as a last resort).

/cc @mcwhittemore @lyzidiamond @allierowan @bsudekum

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants