Skip to content

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

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

Closed
balsoft opened this issue Nov 24, 2020 · 4 comments · Fixed by #3043
Closed

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

balsoft opened this issue Nov 24, 2020 · 4 comments · Fixed by #3043
Labels
C-bug 🐞 Category: unintended, undesired behavior

Comments

@balsoft
Copy link

balsoft commented Nov 24, 2020

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.

@balsoft balsoft added the C-bug 🐞 Category: unintended, undesired behavior label Nov 24, 2020
@kirelagin
Copy link

For context, this was introduced in c5a39cd.

The problem is that format-num turns the number into a string (with a comma for numbers > 999). On the receiving end of the pluralize function, this string is parsed back into a number using parseFloat, which trips on the comma:

> parseFloat("1,234")
1

cc @carols10cents

@balsoft
Copy link
Author

balsoft commented Nov 24, 2020

The easiest fix should be along the lines of

          {{ format-num category.crates_cnt }} {{ pluralize category.crates_cnt "crate" { withoutCount: true } }}

@balsoft
Copy link
Author

balsoft commented Nov 24, 2020

@Turbo87 Turbo87 changed the title Pluralization of crate counts in categories and keywords, act 2 Pluralization of crate counts in categories and keywords is broken Nov 24, 2020
@Turbo87
Copy link
Member

Turbo87 commented Nov 24, 2020

thanks for the report, @balsoft. should be fixed once #3043 is merged :)

@bors bors closed this as completed in 97bf0a7 Nov 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug 🐞 Category: unintended, undesired behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants