« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/upd8.js
diff options
context:
space:
mode:
Diffstat (limited to 'upd8.js')
-rwxr-xr-xupd8.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/upd8.js b/upd8.js
index a54a886..97ee8bf 100755
--- a/upd8.js
+++ b/upd8.js
@@ -494,6 +494,10 @@ function genStrings(stringsJSON, defaultJSON = null) {
             conjunction: new Intl.ListFormat(code, {type: 'conjunction'}),
             disjunction: new Intl.ListFormat(code, {type: 'disjunction'}),
             unit: new Intl.ListFormat(code, {type: 'unit'})
+        },
+        plural: {
+            cardinal: new Intl.PluralRules(code, {type: 'cardinal'}),
+            ordinal: new Intl.PluralRules(code, {type: 'ordinal'})
         }
     };
 
@@ -523,9 +527,7 @@ function genStrings(stringsJSON, defaultJSON = null) {
 
 const countHelper = (stringKey, argName = stringKey) => (value, {strings, unit = false}) => strings(
     (unit
-        ? `count.${stringKey}.withUnit` + (value === 1
-            ? '.singular'
-            : '.plural')
+        ? `count.${stringKey}.withUnit.` + strings.intl.plural.cardinal.select(value)
         : `count.${stringKey}`),
     {[argName]: strings.intl.number.format(value)});
 
@@ -568,7 +570,7 @@ const count = {
     },
 
     index: (value, {strings}) => {
-        return strings('count.index', {index: value});
+        return strings('count.index.' + strings.intl.plural.ordinal.select(value), {index: value});
     },
 
     number: value => strings.intl.number.format(value),