« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-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'),