From 1704827d045bda62a8e7788bafbb44aa2f62a6f6 Mon Sep 17 00:00:00 2001 From: Ross Smith II Date: Sun, 15 Sep 2024 01:21:18 -0700 Subject: [PATCH] chore(gui): update HumanDuration.js (#9710) Relevant changes: ko: Use correct names for month and hour in Korean (465eaed) Hide unit count if 2 in Arabic (f90d847) --- .../HumanizeDuration.js/humanize-duration.js | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/gui/default/vendor/HumanizeDuration.js/humanize-duration.js b/gui/default/vendor/HumanizeDuration.js/humanize-duration.js index bbe129e3c..ecdd981dc 100644 --- a/gui/default/vendor/HumanizeDuration.js/humanize-duration.js +++ b/gui/default/vendor/HumanizeDuration.js/humanize-duration.js @@ -41,6 +41,7 @@ * @prop {string} [delimiter] * @prop {DigitReplacements} [_digitReplacements] * @prop {boolean} [_numberFirst] + * @prop {boolean} [_hideCountIf2] */ /** @@ -116,6 +117,7 @@ // minute -> د stands for "دقيقة" // second -> ث stands for "ثانية" ar: assign(language("س", "ش", "أ", "ي", "س", "د", "ث", "م ث", ","), { + _hideCountIf2: true, _digitReplacements: ["۰", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"] }), // български (Bulgarian) @@ -177,7 +179,7 @@ // ಕನ್ನಡ (Kannada) kn: language("ವ", "ತ", "ವ", "ದ", "ಗಂ", "ನಿ", "ಸೆ", "ಮಿಸೆ"), // 한국어 (Korean) - ko: language("년", "월", "주", "일", "시", "분", "초", "밀리초"), + ko: language("년", "달", "주", "일", "시간", "분", "초", "밀리초"), // Kurdî (Kurdish) ku: language("sal", "m", "h", "r", "s", "d", "ç", "ms", ","), // ລາວ (Lao) @@ -464,19 +466,25 @@ : Math.floor(unitCount * Math.pow(10, maxDecimalPoints)) / Math.pow(10, maxDecimalPoints); var countStr = normalizedUnitCount.toString(); - if (digitReplacements) { + + if (language._hideCountIf2 && unitCount === 2) { formattedCount = ""; - for (var i = 0; i < countStr.length; i++) { - var char = countStr[i]; - if (char === ".") { - formattedCount += decimal; - } else { - // @ts-ignore because `char` should always be 0-9 at this point. - formattedCount += digitReplacements[char]; - } - } + spacer = ""; } else { - formattedCount = countStr.replace(".", decimal); + if (digitReplacements) { + formattedCount = ""; + for (var i = 0; i < countStr.length; i++) { + var char = countStr[i]; + if (char === ".") { + formattedCount += decimal; + } else { + // @ts-ignore because `char` should always be 0-9 at this point. + formattedCount += digitReplacements[char]; + } + } + } else { + formattedCount = countStr.replace(".", decimal); + } } var languageWord = language[unitName];