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

Add locales as a property to FlaskForm.Meta #399

Closed
wants to merge 3 commits into from
Closed

Add locales as a property to FlaskForm.Meta #399

wants to merge 3 commits into from

Conversation

weinbusch
Copy link

@weinbusch weinbusch commented Feb 12, 2020

Partly fixes #398: I propose to solve this issue by adding a locales property to FlaskForm.Meta. This property dynamically retrieves the current locale by calling i18n.get_locale. This allows DecimalField to render a localized form of the input value.

What I don't like about this solution is that the Locale object returned by get_locale needs to be converted to a language string only to be reassembled into a Locale object later by babel through DecimalField._format_decimal.

@codecov-io
Copy link

codecov-io commented Feb 12, 2020

Codecov Report

Merging #399 into master will decrease coverage by 0.48%.
The diff coverage is 80.76%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #399      +/-   ##
==========================================
- Coverage   98.73%   98.25%   -0.49%     
==========================================
  Files          18       18              
  Lines         949      974      +25     
  Branches       74       75       +1     
==========================================
+ Hits          937      957      +20     
- Misses         12       17       +5
Impacted Files Coverage Δ
flask_wtf/form.py 97.46% <100%> (+0.2%) ⬆️
tests/test_i18n.py 85.5% <75%> (-4.5%) ⬇️
flask_wtf/csrf.py 98.1% <0%> (ø) ⬆️
tests/test_csrf_extension.py 100% <0%> (ø) ⬆️
tests/test_csrf_form.py 100% <0%> (ø) ⬆️
tests/test_recaptcha.py 100% <0%> (ø) ⬆️
tests/test_form.py 100% <0%> (ø) ⬆️
tests/test_file.py 100% <0%> (ø) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc78630...d9c84fb. Read the comment docs.

@azmeuk azmeuk added the i18n label Jul 22, 2023
@weinbusch weinbusch closed this by deleting the head repository Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

Integration of LocaleAwareNumberField and DateTimeField with Flask-Babel
3 participants