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);
Comments
Comment #4
omkar-pd commentedMade changes as per the Proposed resolution.
Comment #5
andy-blumComment #6
omkar-pd commentedComment #9
chrisfromredfinYeah boi, let's get a little modernization in there.