summaryrefslogtreecommitdiffstats
path: root/web_src/js/features/formatting.js
blob: a7ee7ec3cf36f316ea51e31e4850bc8d13fdf06b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import {prettyNumber} from '../utils.js';

const {lang} = document.documentElement;

export function initFormattingReplacements() {
  // replace english formatted numbers with locale-specific separators
  for (const el of document.getElementsByClassName('js-pretty-number')) {
    const num = Number(el.getAttribute('data-value'));
    const formatted = prettyNumber(num, lang);
    if (formatted && formatted !== el.textContent) {
      el.textContent = formatted;
    }
  }
}