浏览代码

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)
Ross Smith II 1 年之前
父节点
当前提交
1704827d04
共有 1 个文件被更改,包括 19 次插入11 次删除
  1. 19 11
      gui/default/vendor/HumanizeDuration.js/humanize-duration.js

+ 19 - 11
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 {
+      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);
       }
-    } else {
-      formattedCount = countStr.replace(".", decimal);
     }
 
     var languageWord = language[unitName];