fix: pluralize unit word using the maxDecimalPoints-truncated count
When maxDecimalPoints truncates a unit count to exactly 1, the rendered
number showed 1 while the word was pluralized from the raw count (for
example humanizeDuration(1500, { maxDecimalPoints: 0 }) returned
"1 seconds"). Pluralize from the normalized count that is actually
displayed so the number and word agree.
This commit is contained in:
1 parent
194562d9da
commit
93dd2b2f06
3 files changed
+105
-1
No files matched your search
@@ -1382,7 +1382,10 @@
|
||||
var languageWord = language[unitName];
|
||||
var word;
|
||||
if (typeof languageWord === "function") {
|
||||
word = languageWord(unitCount);
|
||||
// Pluralize based on the count that is actually rendered. When
|
||||
// `maxDecimalPoints` truncates the count (for example 1.5 -> "1"),
|
||||
// the word must agree with the displayed number, not the raw one.
|
||||
word = languageWord(normalizedUnitCount);
|
||||
} else {
|
||||
word = languageWord;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user