Skip to content

Pluralization of crate counts in categories and keywords is broken #3042

Closed
@balsoft

Description

@balsoft

Describe the bug

Visiting https://crates.io/categories, I see

Algorithms 927 crates

API bindings 1,382 crate

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://crates.io/categories or https://crates.io/keywords/
  2. Examine the pluralization of the word "crate" in crate counts of categories or keywords; all numbers which are between 1000 and 1999 inclusive come with a singular "crate"

Expected behavior

I'm not a native English speaker, but I do believe that 1,382 should come with a plural "crates" and not singular "crate".

Screenshots

A screenshot demonstrating the different pluralization

Desktop (please complete the following information):

  • OS: NixOS GNU/Linux, nixpkgs-unstable
  • Browser: Firefox 82.0.2 (64-bit)

Additional context

I believe the problem comes from the fact that crates.io passes "1,382", "crate" to https://github.com/emberjs/ember-inflector 's pluralize(count, word) function, which internally uses parseFloat(count) !== 1 to determine cases where plural should be used, and parseFloat("1,382") happens to be precisely 1, thus leading to pluralize returning singular.

The "act 2" is was in the issue name because of #513, which is a very similar issue, and I believe the fix for it introduced this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bug 🐞Category: unintended, undesired behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions