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
Locale __init__/parse inconsistencies #283
Comments
Well, I see two approaches:
|
IMO, keeping
The problem is that Each given part of the locale should probably be validated separately. Something like...
This should also have the side effect of fixing the "I passed you a number" uncaught exception in the validator that isn't working as expected. |
The alias tables don't contain every language/territory/script/variant there is, though. Maybe if we start by validating the pieces to be alphabetical if they exist, and then build up to more precise validation later? |
Forgive me as I haven't dug too deeply into the code, but if those tables aren't complete and you can get a In any case, if you can't look it up directly then ensuring that each piece is only alpha or only alpha/num and of the correct length (if applicable) as you suggest would be a good starting point for better validation of constructor arguments. |
Those are alias tables, such as "variant_aliases": {
"HEPLOC": "ALALC97",
"AALAND": "AX",
"POLYTONI": "POLYTON"
} that map previously/occasionally used names into the canonical names used by the CLDR. The actual knowledge of which locales are available stems from the existence of a |
Babel 2.1.1, Python 2.7.5
Locale.parse('en_US')
returnsLocale('en', territory='US')
but
Locale('en_US')
returnsLocale('en_US')
when I would expect
Locale('en_US')
returnsLocale('en', territory='US')
orUnknownLocaleError
Locale.parse(12)
intentionally raisesTypeError: Unxpected value for identifier: 12
but
Locale(12)
causes an uncaughtTypeError
The text was updated successfully, but these errors were encountered: