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

Parsing of mixed-cased locale ID. #361

Merged
merged 5 commits into from
Mar 3, 2016
Merged

Parsing of mixed-cased locale ID. #361

merged 5 commits into from
Mar 3, 2016

Conversation

kdeldycke
Copy link
Contributor

Following #351, it seems that mixed-cased locale IDs are not properly checked as existing depending on the platform.

The issue lies in babel.localedata.exists() which rely on filesystem assets. As a result, mixed-cased locale IDs are properly parsed on OSX (case-insensitive filesystem) but not on Linux.

The first commit demonstrate the issue depending on the system.
The second commit ensure that locale IDs recognized by Babel are uniques, even if lower-cased.
The third commit fix to the issue.

@kdeldycke
Copy link
Contributor Author

Looks like this issue relates to #283.

@codecov-io
Copy link

Current coverage is 89.68%

Merging #361 into master will increase coverage by +0.02% as of bb16d60

@@            master    #361   diff @@
======================================
  Files           23      23       
  Stmts         3794    3801     +7
  Branches         0       0       
  Methods          0       0       
======================================
+ Hit           3402    3409     +7
  Partial          0       0       
  Missed         392     392       

Review entire Coverage Diff as of bb16d60

Powered by Codecov. Updated on successful CI builds.

@@ -24,15 +25,22 @@
_dirname = os.path.join(os.path.dirname(__file__), 'locale-data')


def normalize_locale(name):
"""Return a normalized locale ID or `None` if the ID is not recognized."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain what "normalization" means in the docstring?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akx
Copy link
Member

akx commented Mar 3, 2016

Nice, thanks @kdeldycke!

(CI: I'm not waiting for Appveyor, since most builds completed and some failed due to ephemeral errors.)

akx added a commit that referenced this pull request Mar 3, 2016
@akx akx merged commit 85239b2 into python-babel:master Mar 3, 2016
@kdeldycke
Copy link
Contributor Author

Thanks @akx for the quick merge! 😃

@kdeldycke kdeldycke deleted the mixed_cased_locale_id branch March 3, 2016 18:15
if name == locale_id.lower():
return locale_id


def exists(name):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, greedy method.
I'm really looking forward to #305 !

(just an observation, please ignore :)

@jtwang
Copy link
Contributor

jtwang commented Mar 3, 2016

Ah, crud, didn't notice this was already merged into master. Feel free to ignore all my comments, none of them are major. :)

@akx
Copy link
Member

akx commented Mar 3, 2016

All comments were duly noted and processed, don't fret :D

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

Successfully merging this pull request may close these issues.

5 participants