Change decimal and thousands separators in dashboard according to local settings

The separators used in the dashboard for decimals (dot) and thousands (comma) look strange in non-englisch speaking countries.

There is an older feature request addressing the issue, saying it will be solved in the new http://web.pi-hole.net/ dashboard.

As it is unclear when the updated dasboard will be available, it would be nice if also the current dashboard would respected local settings for separators.

That's the reason why I wrote already in the current dashboard. I think it might be easier and faster to change the current implementation than to attract new developerd. See this post

1 Like

The locale parsing is done inside the API (server-side) using the PHP function number_format().

Docs: https://www.php.net/manual/en/function.number-format.php

We could likely change this line from

$stats[$tmp[0]] = number_format($tmp[1]);

to

$locale = localeconv();
$stats[$tmp[0]] = number_format($tmp[1], $locale["decimal_point"], $locale["thousands_sep"]);

A better approach will be to do the formatting on the client side using something like

Thanks for the reply - I'll have a look later.

Just saw that the separators are not consistent within the dashboard - they are different in the long term query page.

I agree.
A lot of users might use pre-made images (of raspbian, or other distribution) which might have different local settings than their clients they use to access the Web GUI.

Yes. This is also why we're already doing the timestamp conversion client-side. This has the nice consequence, that you are, e.g., seeing your Pi-hole's statistics in the local time of the country your currently visiting (assuming your're using your Pi-hole over VPN). At the same time, my wife was able to see the statistics in her local time at home - on the other side of the planet.

I'll check this. Another thing for v5.1.

:+1::+1: