mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Fixed word count grammar
Closes #349 - Added utility function to pluralize when appropriate.
This commit is contained in:
parent
cd5c954aae
commit
5d9f19fa80
2 changed files with 16 additions and 3 deletions
13
ghost/admin/assets/lib/jquery-utils.js
vendored
13
ghost/admin/assets/lib/jquery-utils.js
vendored
|
@ -82,4 +82,17 @@
|
|||
|
||||
$('.overlay').hideAway(); // TODO: Move to a more sensible global file.
|
||||
|
||||
/**
|
||||
* Adds appropriate inflection for pluralizing the singular form of a word when appropriate.
|
||||
* This is an overly simplistic implementation that does not handle irregular plurals.
|
||||
* @param {Number} count
|
||||
* @param {String} singularWord
|
||||
* @returns {String}
|
||||
*/
|
||||
$.pluralize = function inflect(count, singularWord) {
|
||||
var base = [count, ' ', singularWord];
|
||||
|
||||
return (count === 1) ? base.join('') : base.concat('s').join('');
|
||||
};
|
||||
|
||||
}());
|
|
@ -305,9 +305,9 @@
|
|||
preview.innerHTML = this.converter.makeHtml(this.editor.getValue());
|
||||
view.$('.js-drop-zone').upload({editor: true});
|
||||
Countable.once(preview, function (counter) {
|
||||
view.$('.entry-word-count').text(counter.words + ' words');
|
||||
view.$('.entry-character-count').text(counter.characters + ' characters');
|
||||
view.$('.entry-paragraph-count').text(counter.paragraphs + ' paragraphs');
|
||||
view.$('.entry-word-count').text($.pluralize(counter.words, 'word'));
|
||||
view.$('.entry-character-count').text($.pluralize(counter.characters, 'character'));
|
||||
view.$('.entry-paragraph-count').text($.pluralize(counter.paragraphs, 'paragraph'));
|
||||
});
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue