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
Properly localize numbers #8445
Comments
cockpit.format_number() in already contains this comment:
Would implementing this change there be considered an API break in your opinion? If not, do we basically need to go all over the place, changing each separate location? |
IMHO fixing it centrally is better than wrapping all invocations of this with |
Modify format_number() to use .toLocaleString() to format a locale-correct decimal separator, while avoiding thousands separators. MDN says that the 'options' parameter is not supported on at least some versions of mobile browsers, so we might have a minor regression there, but this is not a huge issue, and nicer than having more complicated code. Expand the test-format testcase to re-run all of the tests under locale 'de' to ensure that we are getting properly-formatted numbers in that case (ie: comma as the decimal separator). Closes cockpit-project#8960 Fixes cockpit-project#8445
Modify format_number() to use .toLocaleString() to format a locale-correct decimal separator, while avoiding thousands separators. MDN says that the 'options' parameter is not supported on at least some versions of mobile browsers, so we might have a minor regression there, but this is not a huge issue, and nicer than having more complicated code. Expand the test-format testcase to re-run all of the tests under locale 'de' to ensure that we are getting properly-formatted numbers in that case (ie: comma as the decimal separator). Fixes #8445 Closes #8960
We currently don't properly localize numbers with thousands or decimal separators. E. g. when switching language to German, the network page shows:
and the storage page shows:
Our localization API does not have a function for formatting numbers according to the current locale, but I figure we don't really need one: Our code could just use
If we add an API to base, we need some fallback anyway as we might run against an older cockpit-bridge package (like on RHEL or with containers).
The text was updated successfully, but these errors were encountered: