Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pluralize function at correcting #187

Closed
alexygreen opened this issue Feb 24, 2016 · 0 comments
Closed

Pluralize function at correcting #187

alexygreen opened this issue Feb 24, 2016 · 0 comments
Labels
Milestone

Comments

@alexygreen
Copy link

Hello,
I just detect a minor bug in your script for the "pluralize".

Numéric> 1 = Plurialize string OK
Numéric = 1 = singularize string OK
Numéric = 0 = Singlularize string KO

I thank in advance the creator of this script to modify its code.

Update if (Math.abs(count) === 1) by if (Math.abs(count) === 1 || Math.abs(count) === 0)

function pluralize(format, count) { 
        var plural = "s", singular = "";
        if (format) {                            
            format = format.replace(/(:|;|\s)/gi, "").split(/\,/);
            if (format.length === 1) { 
                plural = format[0];        
            } else {                             
                singular = format[0];    
                plural = format[1];        
            }                                       
        }                                           
        if (Math.abs(count) === 1 || Math.abs(count) === 0 ) { 
            return singular;                                                          
        } else {                                                                           
            return plural;                                                              
        }                                                                                     
    } 
@hilios hilios added the bug label Feb 25, 2016
@hilios hilios added this to the 2.0.4 milestone Feb 25, 2016
@hilios hilios mentioned this issue Aug 3, 2016
11 tasks
@hilios hilios closed this as completed in 0973e35 Aug 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants