Skip to content

Commit 44ab81e

Browse files
committed
add dual & restrictedPlural
1 parent 14e3aca commit 44ab81e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ function writtenNumber(n, options) {
137137
str = r > 1 && unit.plural && (!unit.avoidInNumberPlural || !m)
138138
? unit.plural
139139
: unit.singular;
140+
// Languages with dual
140141
str = (r === 2 && unit.dual) ? unit.dual : str;
142+
// Use plural only for <= 10
143+
str = (r > 10 && unit.restrictedPlural) ? unit.singular : str;
141144
}
142145

143146
if (
@@ -179,8 +182,14 @@ function writtenNumber(n, options) {
179182
ret.slice(1)
180183
);
181184
}
182-
183-
return ret.reverse().join(" ");
185+
// Languages that have separators for all. Not only base and unit
186+
if (language.allSeparator) {
187+
for (let j = 0; j < ret.length-1; j++) {
188+
ret[j] = language.allSeparator + ret[j];
189+
}
190+
}
191+
var result = ret.reverse().join(" ");
192+
return result;
184193
}
185194

186195
function handleSmallerThan100(n, language, unit, baseCardinals, options) {

0 commit comments

Comments
 (0)