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

Keep @modifiers when parsing locales #947

Merged
merged 12 commits into from
Jan 26, 2023

Conversation

madduck
Copy link
Contributor

@madduck madduck commented Jan 18, 2023

Locale modifiers ("@Variants") are described in the GNU gettext documentation like this:

The ‘@variant’ can denote any kind of characteristics that is not
already implied by the language ll and the country CC. […] It can also
denote a dialect of the language, …

Wherein Babel previously would discard these, this patch stores the modifier information in the Locale objects, handling string representation accordingly.

Not implemented is the lookup of a meaningful description of modifiers, but instead — for now — an identity mapping is provided.

All tests pass. Furthermore, integration with flask-babel has been verified to work.

Resolves: #946
Signed-off-by: martin f. krafft [email protected]

Copy link
Member

@akx akx left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution!
Some initial thoughts and comments within; you'll probably also need to rebase since #949 just landed...

babel/core.py Outdated Show resolved Hide resolved
babel/core.py Show resolved Hide resolved
babel/core.py Outdated Show resolved Hide resolved
babel/core.py Outdated Show resolved Hide resolved
babel/core.py Show resolved Hide resolved
babel/core.py Outdated Show resolved Hide resolved
babel/core.py Outdated Show resolved Hide resolved
babel/core.py Outdated Show resolved Hide resolved
babel/core.py Outdated Show resolved Hide resolved
babel/core.py Outdated Show resolved Hide resolved
madduck added a commit to madduck/babel that referenced this pull request Jan 20, 2023
madduck added a commit to madduck/babel that referenced this pull request Jan 20, 2023
madduck added a commit to madduck/babel that referenced this pull request Jan 20, 2023
madduck added a commit to madduck/babel that referenced this pull request Jan 20, 2023
madduck added a commit to madduck/babel that referenced this pull request Jan 20, 2023
madduck added a commit to madduck/babel that referenced this pull request Jan 20, 2023
@madduck
Copy link
Contributor Author

madduck commented Jan 20, 2023

@akx Thank you for your time. I addressed most of your comments, and left an open question in the above. Happy to proceed any way, just let me know what you prefer.

madduck added a commit to madduck/babel that referenced this pull request Jan 20, 2023
madduck added a commit to madduck/babel that referenced this pull request Jan 20, 2023
madduck added a commit to madduck/babel that referenced this pull request Jan 20, 2023
madduck added a commit to madduck/babel that referenced this pull request Jan 20, 2023
madduck added a commit to madduck/babel that referenced this pull request Jan 20, 2023
madduck added a commit to madduck/babel that referenced this pull request Jan 20, 2023
@madduck madduck requested a review from akx January 21, 2023 22:00
Copy link
Member

@akx akx left a comment

Choose a reason for hiding this comment

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

Thanks for implementing the suggested changes!

There's a couple more comments within, but I think we're pretty close. Thanks :)

babel/core.py Outdated Show resolved Hide resolved
babel/core.py Outdated Show resolved Hide resolved
babel/core.py Show resolved Hide resolved
babel/core.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jan 25, 2023

Codecov Report

Merging #947 (83188f0) into master (6bf793a) will decrease coverage by 0.02%.
The diff coverage is 93.10%.

@@            Coverage Diff             @@
##           master     #947      +/-   ##
==========================================
- Coverage   90.91%   90.89%   -0.02%     
==========================================
  Files          25       25              
  Lines        4327     4340      +13     
==========================================
+ Hits         3934     3945      +11     
- Misses        393      395       +2     
Impacted Files Coverage Δ
babel/core.py 96.31% <93.10%> (-0.45%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

madduck added a commit to madduck/babel that referenced this pull request Jan 25, 2023
madduck added a commit to madduck/babel that referenced this pull request Jan 25, 2023
madduck added a commit to madduck/babel that referenced this pull request Jan 25, 2023
madduck added a commit to madduck/babel that referenced this pull request Jan 25, 2023
madduck added a commit to madduck/babel that referenced this pull request Jan 25, 2023
madduck added a commit to madduck/babel that referenced this pull request Jan 25, 2023
@madduck madduck requested a review from akx January 25, 2023 20:13
@akx akx added this to the Babel 2.12 milestone Jan 25, 2023
@akx akx added the feature label Jan 25, 2023
Copy link
Member

@akx akx left a comment

Choose a reason for hiding this comment

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

Tests are failing, can you take a look? Thanks.

babel/core.py Show resolved Hide resolved
@madduck
Copy link
Contributor Author

madduck commented Jan 25, 2023

Sorry for the failing tests, was due to the 4/5 tuple return depending on modifier==None. I am not actually very sure it's a good idea, but I see your point. Fixed now.

madduck and others added 12 commits January 25, 2023 22:24
Locale modifiers ("@Variants") are described in the GNU gettext
documentation like this:

> The ‘@variant’ can denote any kind of characteristics that is not
> already implied by the language ll and the country CC. […] It can also
> denote a dialect of the language, …

Wherein Babel previously would discard these, this patch stores the
modifier information in the `Locale` objects, handling string
representation accordingly.

Not implemented is the lookup of a meaningful description of modifiers,
but instead — for now — an identity mapping is provided.

Resolves: python-babel#946
Signed-off-by: martin f. krafft <[email protected]>
Signed-off-by: martin f. krafft <[email protected]>
Signed-off-by: martin f. krafft <[email protected]>
Copy link
Member

@akx akx left a comment

Choose a reason for hiding this comment

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

Thanks, looks good!

@akx akx merged commit d019ed1 into python-babel:master Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not discard locale modifiers (@variants)
2 participants