Add Zotero.Utilities.pluralize()
This makes it a little easier to use the proper plural form of a word. Currently this only supports English forms and is used only in debug output. For proper plural form support, use PluralForm.jsm.
This commit is contained in:
parent
397ea5875a
commit
b30e168c21
1 changed files with 16 additions and 0 deletions
|
@ -866,6 +866,22 @@ Zotero.Utilities = {
|
||||||
return str + '\u2026' + (countChars ? ' (' + str.length + ' chars)' : '');
|
return str + '\u2026' + (countChars ? ' (' + str.length + ' chars)' : '');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the proper plural form of a string
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* @return {String}
|
||||||
|
*/
|
||||||
|
pluralize: function (num, forms) {
|
||||||
|
return num == 1 ? forms[0] : forms[1];
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Port of PHP's number_format()
|
* Port of PHP's number_format()
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue