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

Properly localize Download/Stargazer Counts within settings-view #526

Merged
merged 2 commits into from
May 13, 2023

Conversation

confused-Techie
Copy link
Member

Getting to the bottom of this issue, seems to stem from as soon as the backend migrated to the new package builder.

The backend now returns strings for both stargazer_count and downloads instead of integers.

Meaning that when settings-view used:

this.refs.downloadCount.textContent = data.downloads ? data.downloads.toLocaleString() : '';

That .toLocaleString() would just return the same string it received, rather than operate on it. So that a string of 1000 stayed as 1000 rather than 1,000.

So what I've done here is first parsed any strings on these values to integers, then we localize the value itself, to match with how the user expects in their region.

I've confirmed that attempting to convert any integers to an integer has no negative effects, so that when this is fixed on the backend (which it also should be) this solution will not cause any issues.

Really while I do plan on fixing it on the backend, it still makes sense to me to fix it here as well, to ensure we always show the user what they want to see.

So beyond that lets look at the before and after:

Before

image

After

image


Resolves #441

Copy link
Member

@Daeraxa Daeraxa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes perfect sense to me

@confused-Techie
Copy link
Member Author

With approval, and fully passing tests, and the fact this closes an issue, I'll go ahead and merge.

@confused-Techie confused-Techie merged commit a364065 into master May 13, 2023
@confused-Techie confused-Techie deleted the localize-package-numbers branch May 13, 2023 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing commas from package install count
2 participants