From 7ac0940bd56f28257d327d02680ffbc33e000d51 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Thu, 3 Nov 2022 19:54:00 +0000 Subject: [PATCH] Try catch for NumberFormat. See https://github.com/TeamPiped/Piped/pull/1675#issuecomment-1302587072 --- src/main.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main.js b/src/main.js index 2671d470..efe2bae9 100644 --- a/src/main.js +++ b/src/main.js @@ -88,12 +88,17 @@ const mixin = { return str; }, numberFormat(num) { - const formatter = Intl.NumberFormat( - `${this.getPreferenceString("hl")}-${this.getPreferenceString("region")}`, - { - notation: "compact", - }, - ); + var loc = `${this.getPreferenceString("hl")}-${this.getPreferenceString("region")}`; + + try { + Intl.getCanonicalLocales(loc); + } catch { + loc = undefined; + } + + const formatter = Intl.NumberFormat(loc, { + notation: "compact", + }); return formatter.format(num); }, addCommas(num) {