Problem/Motivation

ProjectBrowser.svelte and ModulePage.svelte use complicated regexes to format numbers with comma number separators (1000000 -> 1,000,000)

We should replace these regex-based methods with the more readable & localizable Intl.NumberFormat class.

In this way, users get number separators they are used to in their own language - for example, German-speakers will see one million formatted as "1.000.000"

Proposed resolution

In util.js we should export a new instance of the number formatter:

export const NumberFormatter = new Intl.NumberFormat(navigator.language);

Then, as needed, we can use this new object to format numbers:

setTimeout(() => {
  announce(
    Drupal.t('@count Results for @active_tab, Sorted by @sortText', {
      '@count': numberFormatter.format($rowsCount),
      '@sortText': sortText,
      '@active_tab': ACTIVE_PLUGINS[$activeTab],
    }),
  );
}, 210);
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

andy-blum created an issue. See original summary.

omkar-pd made their first commit to this issue’s fork.

omkar-pd’s picture

Status: Active » Needs review

Made changes as per the Proposed resolution.

andy-blum’s picture

Status: Needs review » Needs work
omkar-pd’s picture

Status: Needs work » Needs review

chrisfromredfin made their first commit to this issue’s fork.

chrisfromredfin’s picture

Status: Needs review » Fixed

Yeah boi, let's get a little modernization in there.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.