www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit f2af77498ba3e312d92c3765365a4f1dff1f7901
parent e2d7c7e999d2cddd26b30780c2f37cd41d501c97
Author: Dan Stillman <dstillman@zotero.org>
Date:   Fri,  7 Jul 2017 18:18:00 -0400

Allow single string in Zotero.Utilities.pluralize()

Zotero.Utilities.pluralize(5, 'tag') will produce 'tags' automatically

Diffstat:
Mchrome/content/zotero/xpcom/utilities.js | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js @@ -873,11 +873,15 @@ Zotero.Utilities = { * For now, this is only used for debug output in English. * * @param {Integer} num - * @param {String[]} forms - An array of plural forms (e.g., ['object', 'objects']); currently only - * the two English forms are supported, for 1 and 0/many + * @param {String[]|String} forms - If an array, an array of plural forms (e.g., ['object', 'objects']); + * currently only the two English forms are supported, for 1 and 0/many. If a single string, + * 's' is added automatically for 0/many. * @return {String} */ pluralize: function (num, forms) { + if (typeof forms == 'string') { + forms = [forms, forms + 's']; + } return num == 1 ? forms[0] : forms[1]; },