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

Warn that the "tags" whitelist is order sensitive #4

Open
dantman opened this issue Feb 8, 2020 · 0 comments
Open

Warn that the "tags" whitelist is order sensitive #4

dantman opened this issue Feb 8, 2020 · 0 comments

Comments

@dantman
Copy link

dantman commented Feb 8, 2020

> langtag.lookup(['en', 'en-CA'], ['en-CA'])
'en'
> langtag.lookup(['en-CA', 'en'], ['en-CA'])
'en-CA'

If a root locale like en comes before subtags like en-CA in the tags whitelist langtags will never reach the more specific locale, even if the order of the range user locale list indicates that the more specific locale is preferred.

Documentation should probably warn that you need to put any shorter locales after the more specific locales in the tags list.

This is important because some locale libraries (cldr, Globalize, ...) omit an en-US locale and instead make en equivalent to en-US. So a lookup for ['en-US', 'en-CA'] would actually be ['en', 'en-CA'] and if not re-ordered would result in US English always being used even if other non-US English locales are also supported.

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