Add locales as a property to FlaskForm.Meta
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 Report
Merging #399 into master will decrease coverage by
0.48%. The diff coverage is80.76%.
@@ 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%) |
:arrow_up: |
| tests/test_i18n.py | 85.5% <75%> (-4.5%) |
:arrow_down: |
| flask_wtf/csrf.py | 98.1% <0%> (ø) |
:arrow_up: |
| tests/test_csrf_extension.py | 100% <0%> (ø) |
:arrow_up: |
| tests/test_csrf_form.py | 100% <0%> (ø) |
:arrow_up: |
| tests/test_recaptcha.py | 100% <0%> (ø) |
:arrow_up: |
| tests/test_form.py | 100% <0%> (ø) |
:arrow_up: |
| tests/test_file.py | 100% <0%> (ø) |
:arrow_up: |
| ... and 1 more |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update dc78630...d9c84fb. Read the comment docs.