-
-
Notifications
You must be signed in to change notification settings - Fork 562
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
Use automatic percent formatting #2972
Conversation
My first time doing something in JS, so I'm not sure if it does what it wants to do right now. Untested. |
9897057
to
acce30a
Compare
Can anyone tell me why the CI is still failing? After many wrestling with JS functions, I finally got it to work I think, but I cannot make the CI happy :). Any assistance is appreciated. |
From file export function toPercent(number, fractionDigits = 0) {
const userLocale = navigator.language || "en-US";
return new Intl.NumberFormat(userLocale, {
style: "percent",
minimumFractionDigits: fractionDigits,
maximumFractionDigits: fractionDigits,
}).format(number / 100);
} as follows. export function toPercent(number, fractionDigits = 0) {
const userLocale = navigator.language || "en-US";
return new Intl.NumberFormat(userLocale, {
style: "percent",
minimumFractionDigits: fractionDigits,
maximumFractionDigits: fractionDigits,
}).format(number / 100);
} Spaces may not be set correctly. |
I fixed the editor CI but still getting the following Tests / Node error:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignoring the CI tests failing for now (and as a hint, you can run the tests locally with npm run test
)
If there is any value in this PR - perhaps it should also be expanded to account for regional formatting differences in all numbers, not just the percentages. Example: In the UK the thousand separator is a ,
, whereas in Germany it is a .
It automatically formats the decimal separators as well, so no worries there. If there are other places in the code base that does not use localised formatting (not percent values) would love to help in a future PR. In the previous version there was this PHP code, but it looks like removed. I couldn't find the equivalent though. |
We set Lines 59 to 60 in 8f23b3a
But there is no |
I just use plain Vim. :) |
Worked it out locally. It's because your additional file has the |
The CI is now telling me to use 2 spaces after file rename... |
This is expected. and desired. Lines 17 to 18 in be05b0f
|
1abbfab
to
67b6787
Compare
YES. AT LAST, YES. Ready now. Thanks for all the help. |
5d18647
to
9900c8b
Compare
you need to add |
Signed-off-by: Emir SARI <[email protected]>
Ah, sorry. Added now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at other numbers. We use If you're up for the challenge, see if you can find and fix more localisation issues :) One place I see already might be the top x domains tables, note the numbers in the screenshots below are arabic at the top, yet not in the tables |
Looks great! By the way, where did the Memory Usage percent value did disappear to? In the closed PR of mine against master, I fixed that in PHP as well, but in the development branch it is not there... I'll check other numbers and fix them too! |
You're right. CPU Percentage as well. Comparing the changes in #2971, and in this one - perhaps you forgot to include them in this one after basing on PS. |
It was all in Lua. Anyway, I'll do a fresh rebase and see what happens. :) |
Thank you for your contribution to the Pi-hole Community!
Please read the comments below to help us consider your Pull Request.
We are all volunteers and completing the process outlined will help us review your commits quicker.
Please make sure you
What does this PR aim to accomplish?:
It uses automatic percent formatting in the code. This automatically formats the percent values in accordance with the user's locale. For instance, some languages use different percent signs, and some use different posititoning other than standard 100%.
How does this PR accomplish the above?:
By using the appropriate
NumberFormatter
API.By submitting this pull request, I confirm the following:
git rebase
)