ui icon indicating copy to clipboard operation
ui copied to clipboard

Use of period/comma as decimal point is inconsistent across the app

Open maltekliemann opened this issue 2 years ago • 3 comments

Many fields use a decimal point, others a comma. I think we should go with a decimal point everywhere. I come from a region where it's customary to use a comma as a decimal point and a period as thousands separator, and I still would prefer using a period because that seems to me to be the standard in finance.

maltekliemann avatar Dec 08 '23 09:12 maltekliemann

lang="en"

Robiquet avatar Dec 11 '23 16:12 Robiquet

This will depend on the user's region; for example in North America I have never seen a period used as a thousands separator. There's a way in javascript to detect the users settings in their browser that can be used to provide a different number formatting to match their preferences.

I'm proposing we do something like this:

export const formatNumberCompact = (
  num: number | bigint,
  maximumSignificantDigits = 3,
) => {
  const userLocale = navigator.language || "en-US";

  // Ensure displaying absolute zeros are unsigned(-), because javascript sucks sometimes.
  if (num === 0 || num === 0n) num = 0;

  return new Intl.NumberFormat(userLocale, {
    maximumSignificantDigits: maximumSignificantDigits,
    notation: "compact",
  }).format(num);
};

We currently have this function but without the userLocale = navigator.language || "en-US". We just haven't implemented it in all areas consistently so if we are good with the formatting decision I'll go ahead and fix the remaining inconsistencies we have.

robhyrk avatar May 30 '24 16:05 robhyrk

I think the main point is that we should make everything on the page uniform. 👍 Whether we go with commas as thousands separator despite the user's locale or we use the user's local or we let the user define a setting isn't as important. So just using the US convention seems fine to me.

maltekliemann avatar Jun 04 '24 19:06 maltekliemann