UPDATE: I have renamed this class HGrammar to prevent any conflict.
This extension is a simple helper class which I use to make sure text generated by my application is natural.
Plurals - no need to put bracket(s) after your word(s). Lists - produce a nice, simple and clean list from an array. Vowels - Words beginning with a vowel are prefixed with a/an.
Resources ¶
Documentation ¶
Requirements ¶
- Yii 1.0 or above
Installation ¶
- Extract the release file under
protected/components
or I actually useprotected/helpers
Usage ¶
Examples:
// PLURALS
echo HGrammar::plural($commentCount,'comment');
// Output: 'comment' if commentCount is 1, otherwise 'comments'
// LISTS
$people = array('John','Trevor','Qiang');
echo HGrammar::commaList($people);
// Output: 'John, Trevor and Qiang'.
See PHPDoc for Vowels function
Change Log ¶
July 1, 2010 ¶
- Initial release.
July 2, 2010 ¶
- Changed class name to HGrammar instead of CGrammar
Brilliant =)
This one is going to come in very handy!
Excellent Idea!
Never a fan of adding an if block for (count == 1).
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.