|
699 | 699 |
|
700 | 700 |
|
701 | 701 | /** |
702 | | - * This function will pluralize or singularlize a String appropriately based on an integer value |
| 702 | + * This function will pluralize or singularlize a String appropriately based on a number value |
703 | 703 | * @public |
704 | 704 | * @function |
705 | 705 | * @param {String} str The subject string. |
|
715 | 715 | * inflection.inflect( 'octopuses' 1 ); // === 'octopus' |
716 | 716 | * inflection.inflect( 'Hats' 1 ); // === 'Hat' |
717 | 717 | * inflection.inflect( 'guys', 1 , 'person' ); // === 'person' |
| 718 | + * inflection.inflect( 'inches', 1.5 ); // === 'inches' |
718 | 719 | * inflection.inflect( 'person', 2 ); // === 'people' |
719 | 720 | * inflection.inflect( 'octopus', 2 ); // === 'octopuses' |
720 | 721 | * inflection.inflect( 'Hat', 2 ); // === 'Hats' |
721 | 722 | * inflection.inflect( 'person', 2, null, 'guys' ); // === 'guys' |
722 | 723 | */ |
723 | 724 | inflect : function ( str, count, singular, plural ){ |
724 | | - count = parseInt( count, 10 ); |
| 725 | + count = parseFloat( count, 10 ); |
725 | 726 |
|
726 | 727 | if( isNaN( count )) return str; |
727 | 728 |
|
728 | | - if( count === 0 || count > 1 ){ |
729 | | - return inflector._apply_rules( str, plural_rules, uncountable_words, plural ); |
730 | | - }else{ |
| 729 | + if( count === 1 ){ |
731 | 730 | return inflector._apply_rules( str, singular_rules, uncountable_words, singular ); |
| 731 | + }else{ |
| 732 | + return inflector._apply_rules( str, plural_rules, uncountable_words, plural ); |
732 | 733 | } |
733 | 734 | }, |
734 | 735 |
|
|
0 commit comments