]> BookStack Code Mirror - bookstack/blobdiff - resources/js/services/translations.js
Reverted shift change to old migration
[bookstack] / resources / js / services / translations.js
index b595a05e6f95b8e9a2d7862adbc5b5d003f6e163..62bb51f56aacb5f0216e0e4621ffdfcae0d34481 100644 (file)
@@ -47,7 +47,19 @@ class Translator {
      */
     getPlural(key, count, replacements) {
         const text = this.getTransText(key);
-        const splitText = text.split('|');
+        return this.parsePlural(text, count, replacements);
+    }
+
+    /**
+     * Parse the given translation and find the correct plural option
+     * to use. Similar format at laravel's 'trans_choice' helper.
+     * @param {String} translation
+     * @param {Number} count
+     * @param {Object} replacements
+     * @returns {String}
+     */
+    parsePlural(translation, count, replacements) {
+        const splitText = translation.split('|');
         const exactCountRegex = /^{([0-9]+)}/;
         const rangeRegex = /^\[([0-9]+),([0-9*]+)]/;
         let result = null;