From 1076cd2895a698ce92c5a9dc582bcb96add37591 Mon Sep 17 00:00:00 2001 From: Robert Morrison Date: Sat, 8 Oct 2022 03:45:55 +0100 Subject: [PATCH] fix: Get language instead of hard coding The language data that is used to set the locale of the session is now grabbed from the DOM intstead of relying on a hardcoded value. --- numberFormat.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/numberFormat.js b/numberFormat.js index 99230ab..dbde2c1 100644 --- a/numberFormat.js +++ b/numberFormat.js @@ -37,8 +37,11 @@ // GNU won't support my choice of browser so I won't support their tool function formatNumbers() { + const numbers = document.getElementsByTagName("num"); - const formatter = Intl.NumberFormat(navigator.language); + const documentLanguage = document.documentElement.lang; + const formatter = Intl.NumberFormat(documentLanguage); + for (let num of numbers) { var number = parseFloat(num.innerHTML); if (isNaN(number)) {