From 590cb87a0eead2db19108e699f5bf652f7bf3431 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 10 Mar 2021 10:19:04 -0400 Subject: simplify and un-break count.words() logic --- upd8.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/upd8.js b/upd8.js index 97ee8bf..8dff388 100755 --- a/upd8.js +++ b/upd8.js @@ -576,13 +576,15 @@ const count = { number: value => strings.intl.number.format(value), words: (value, {strings, unit = false}) => { + const num = strings.intl.number.format(value > 1000 + ? Math.floor(value / 100) / 10 + : value); + const words = (value > 1000 - ? strings('count.words.thousand', {words: Math.floor(value / 100) / 10}) - : strings('count.words', {words: value})); + ? strings('count.words.thousand', {words: num}) + : strings('count.words', {words: num})); - return (unit - ? countHelper('words')(words, {strings, unit: true}) - : words); + return strings('count.words.withUnit.' + strings.intl.plural.cardinal.select(value), {words}); }, albums: countHelper('albums'), -- cgit 1.3.0-6-gf8a5