« get me outta code hell

simplify and un-break count.words() logic - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <towerofnix@gmail.com>2021-03-10 10:19:04 -0400
committer(quasar) nebula <towerofnix@gmail.com>2021-03-10 10:19:04 -0400
commit590cb87a0eead2db19108e699f5bf652f7bf3431 (patch)
tree309280d343e185d77e535c4988457d01a7d17034
parent8f0842ab522b238bf3aacd4d6bab2c6d384469bf (diff)
simplify and un-break count.words() logic
-rwxr-xr-xupd8.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/upd8.js b/upd8.js
index 97ee8bf7..8dff388e 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'),