Closed buschmann23 closed 2 years ago
Hi Matthias,
Thanks for this!
Unfortunately, we can't add a new virtual method to AbstractLocalizer because that would be a binary compatibility break. I'll likely introduce such a break in a few years when Qt 6 is released, but until then
1) is there a way to implement this without the new virtual method? 2) Would it be useful to introduce this without the localization part?
Hey Stephen,
thanks for you answer and to spent a bit of time into this project.
One possibility would be to grab the current locale as string from Context::localizer()->currentLocale() to use it to instantiate a new QLocale to localize the numbers.
Or I could use AbstractLocalizer::localizeNumber() additionally to localize for the maybe most used precision of 2.
Merging #36 into master will increase coverage by
0.15%
. The diff coverage is93.85%
.
@@ Coverage Diff @@
## master #36 +/- ##
==========================================
+ Coverage 88.63% 88.79% +0.15%
==========================================
Files 158 160 +2
Lines 10562 10855 +293
==========================================
+ Hits 9362 9639 +277
- Misses 1200 1216 +16
Impacted Files | Coverage Δ | |
---|---|---|
templates/defaultfilters/defaultfilters.h | 98.03% <100%> (+0.03%) |
:arrow_up: |
templates/tests/testfilters.cpp | 99.61% <100%> (+0.02%) |
:arrow_up: |
templates/tests/testinternationalization.cpp | 100% <100%> (ø) |
:arrow_up: |
templates/i18n/i18ntags.h | 94.11% <100%> (+0.78%) |
:arrow_up: |
templates/i18n/l10n_filesize.h | 100% <100%> (ø) |
|
templates/defaultfilters/stringfilters.h | 98% <100%> (+0.08%) |
:arrow_up: |
templates/defaultfilters/stringfilters.cpp | 95.39% <85.29%> (-1.88%) |
:arrow_down: |
templates/lib/util.cpp | 82.14% <87.09%> (+1.89%) |
:arrow_up: |
templates/i18n/l10n_filesize.cpp | 91.26% <91.26%> (ø) |
|
... and 2 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 312e4a4...0721319. Read the comment docs.
Cherry-picked
This implements the filesizeformat filter as it is available in Django (plus some optional features). Additionally it introduces two new tags (l10n_filesize and l10n_filesize_var) for the i18n system to support file sizes with localized number strings. I documented the functionality in the separate commits. I hope this is helpful. :)